Update dependencies (#4)

This commit is contained in:
Uwe Klotz 2022-12-24 18:16:04 +01:00 committed by GitHub
parent eb5f867f05
commit bae00f7456
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 541 additions and 393 deletions

858
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -18,24 +18,22 @@ wasm-opt = ["-Oz", "--enable-mutable-globals"]
crate-type = ["cdylib", "rlib"] crate-type = ["cdylib", "rlib"]
[dependencies] [dependencies]
clap = { version = "3.1.7", features = ["derive"] } vec1 = { version = "1.10.1", features = ["serde"] }
vec1 = { version = "1.6.0", features = ["serde"] } itertools = "0.10.5"
itertools = "0.10.0" serde_with = "2.1.0"
serde_with = "1.6.2"
html5ever = "0.26.0" html5ever = "0.26.0"
percent-encoding = "2.1.0" percent-encoding = "2.2.0"
url = { version = "2.2.0", features = ["serde"] } url = { version = "2.3.1", features = ["serde"] }
regex = "1" regex = "1"
log = "0.4.14" log = "0.4.17"
once_cell = "1.5.2" once_cell = "1.16.0"
scraper = "0.13.0" scraper = "0.13.0"
tokio-futures-byteorder = { version = "0.2.0", features = ["futures"] } byteorder = "1.4.3"
byteorder = "1.4.2" data-url = "0.2.0"
data-url = "0.1.0"
mime = { package = "mime_4", version = "0.4.0-a.0" } mime = { package = "mime_4", version = "0.4.0-a.0" }
serde = { version = "1.0", features = ["derive", "rc"] } serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0" serde_json = "1.0"
futures = "0.3.12" futures = "0.3.25"
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
reqwest = { package = "reqwest-wasm", version = "0.11.15", features = [ reqwest = { package = "reqwest-wasm", version = "0.11.15", features = [
@ -46,9 +44,10 @@ reqwest = { package = "reqwest-wasm", version = "0.11.15", features = [
] } ] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1.1.1", features = ["full"] } clap = { version = "3.2.23", features = ["derive"] }
env_logger = "0.9.0" tokio = { version = "1.22.0", features = ["full"] }
reqwest = { version = "0.11.12", features = [ env_logger = "0.9.3"
reqwest = { version = "0.11.13", features = [
"json", "json",
"cookies", "cookies",
"blocking", "blocking",

View file

@ -1,5 +1,6 @@
use super::IconInfo; use super::IconInfo;
use serde::Serialize; use serde::{Deserialize, Serialize};
use serde_with::{DeserializeFromStr, SerializeDisplay};
use std::{ use std::{
cmp::Ordering, cmp::Ordering,
collections::HashMap, collections::HashMap,
@ -8,7 +9,7 @@ use std::{
}; };
use url::Url; use url::Url;
#[derive(Debug, Clone, PartialOrd, PartialEq, Ord, Eq)] #[derive(Debug, Clone, PartialOrd, PartialEq, Ord, Eq, SerializeDisplay, DeserializeFromStr)]
pub enum IconKind { pub enum IconKind {
AppIcon, AppIcon,
SiteLogo, SiteLogo,
@ -42,7 +43,6 @@ impl FromStr for IconKind {
pub struct Icon { pub struct Icon {
pub url: Url, pub url: Url,
pub headers: HashMap<String, String>, pub headers: HashMap<String, String>,
#[serde(with = "serde_with::rust::display_fromstr")]
pub kind: IconKind, pub kind: IconKind,
#[serde(flatten)] #[serde(flatten)]
pub info: IconInfo, pub info: IconInfo,

View file

@ -1,5 +1,5 @@
use super::{png::get_png_size, IconSize, IconSizes}; use super::{png::get_png_size, IconSize, IconSizes};
use byteorder::{LittleEndian, ReadBytesExt}; use byteorder::{LittleEndian, ReadBytesExt as _};
use futures::prelude::*; use futures::prelude::*;
use std::{ use std::{
convert::TryInto, convert::TryInto,

View file

@ -1,8 +1,14 @@
use super::IconSize;
use byteorder::BigEndian;
use futures::prelude::*;
use std::error::Error; use std::error::Error;
use tokio_futures_byteorder::AsyncReadBytesExt;
use futures::{AsyncRead, AsyncReadExt as _};
use super::IconSize;
async fn read_u16_be<R: AsyncRead + Unpin>(reader: &mut R) -> Result<u16, Box<dyn Error>> {
let mut buf = [0u8; 2];
reader.read_exact(&mut buf).await?;
Ok(u16::from_be_bytes(buf))
}
pub async fn get_jpeg_size<R: AsyncRead + Unpin>( pub async fn get_jpeg_size<R: AsyncRead + Unpin>(
reader: &mut R, reader: &mut R,
@ -43,14 +49,14 @@ pub async fn get_jpeg_size<R: AsyncRead + Unpin>(
} }
// Read the marker length and skip over it entirely // Read the marker length and skip over it entirely
let page_size = reader.read_u16::<BigEndian>().await? as i64; let page_size = read_u16_be(reader).await? as i64;
reader reader
.read_exact(&mut vec![0; (page_size - 2) as usize]) .read_exact(&mut vec![0; (page_size - 2) as usize])
.await?; .await?;
} }
let height = reader.read_u16::<BigEndian>().await?; let height = read_u16_be(reader).await?;
let width = reader.read_u16::<BigEndian>().await?; let width = read_u16_be(reader).await?;
Ok(IconSize::new(width as _, height as _)) Ok(IconSize::new(width as _, height as _))
} }

View file

@ -1,5 +1,5 @@
use super::IconSize; use super::IconSize;
use byteorder::{BigEndian, ReadBytesExt}; use byteorder::{BigEndian, ReadBytesExt as _};
use futures::prelude::*; use futures::prelude::*;
use std::{error::Error, io::Cursor}; use std::{error::Error, io::Cursor};

View file

@ -306,13 +306,14 @@ impl Icons {
/// Fetch all the icons. Ordered from highest to lowest resolution /// Fetch all the icons. Ordered from highest to lowest resolution
/// ///
/// ``` /// ```
/// # async fn run() { /// async fn run() {
/// let icons = Icons::new(); /// let mut icons = site_icons::Icons::new();
/// icons.load_website("https://github.com").await?; /// icons.load_website("https://github.com").await.unwrap();
/// ///
/// let entries = icons.entries().await; /// let entries = icons.entries().await;
/// for icon in entries { /// for icon in entries {
/// println("{:?}", icon) /// println!("{:?}", icon)
/// }
/// } /// }
/// ``` /// ```
pub async fn entries(mut self) -> Vec<Icon> { pub async fn entries(mut self) -> Vec<Icon> {

View file

@ -5,9 +5,10 @@
//! ```rust //! ```rust
//! use site_icons::Icons; //! use site_icons::Icons;
//! //!
//! async fn run() {
//! let mut icons = Icons::new(); //! let mut icons = Icons::new();
//! // scrape the icons from a url //! // scrape the icons from a url
//! icons.load_website("https://github.com").await?; //! icons.load_website("https://github.com").await.unwrap();
//! //!
//! // fetch all icons, ensuring they exist & determining size //! // fetch all icons, ensuring they exist & determining size
//! let entries = icons.entries().await; //! let entries = icons.entries().await;
@ -16,6 +17,7 @@
//! for icon in entries { //! for icon in entries {
//! println!("{:?}", icon) //! println!("{:?}", icon)
//! } //! }
//! }
//! ``` //! ```
#[macro_use] #[macro_use]