Skip to content

Instantly share code, notes, and snippets.

Created Apr 16, 2020
What would you like to do?
use std::collections::HashMap;
use futures::{stream, StreamExt};
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::error::Error;
#[derive(Serialize, Deserialize, Debug)]
struct ProjectsItem {
hash_id: String,
type ProjectsData = Vec<ProjectsItem>;
#[derive(Serialize, Deserialize, Debug)]
struct ProjectsResponse {
data: ProjectsData
#[derive(Serialize, Deserialize, Debug)]
struct ProjectAsset {
image_url: String,
type ProjectAssets = Vec<ProjectsItem>;
#[derive(Serialize, Deserialize, Debug)]
struct ProjectResponse {
assets: ProjectAssets
const PARALLEL_REQUESTS: usize = 2;
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let username = "anniehexample";
let projects_url = format!("{}/projects.json", username);
let client = Client::new();
let projects = client.get(&projects_url)
let mut stream = futures::stream::FuturesUnordered::new();
let bodies = stream::iter(
.map(|project| {
let client = &client;
async move {
client.get(&format!("{}.json", project.hash_id))
println!("{:#?}", bodies);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment