33 lines
731 B
Rust
33 lines
731 B
Rust
use futures::future::join_all;
|
|
use reqwest::{Client, IntoUrl};
|
|
use serde::Deserialize;
|
|
|
|
use crate::{
|
|
icon::{Icon, IconKind},
|
|
Error,
|
|
};
|
|
|
|
#[derive(Deserialize)]
|
|
struct Manifest {
|
|
icons: Vec<ManifestIcon>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
struct ManifestIcon {
|
|
src: String,
|
|
// Not gonna trust or parse the sizes
|
|
}
|
|
|
|
pub async fn scan_manifest(client: &Client, url: impl IntoUrl) -> Result<Vec<Icon>, Error> {
|
|
let manifest: Manifest = client.get(url).send().await?.json().await?;
|
|
Ok(join_all(
|
|
manifest
|
|
.icons
|
|
.into_iter()
|
|
.map(|i| Icon::from_url(client, i.src, IconKind::LinkedInManifest)),
|
|
)
|
|
.await
|
|
.into_iter()
|
|
.filter_map(|i| i.ok())
|
|
.collect())
|
|
}
|