Update dependencies (#4)
This commit is contained in:
parent
eb5f867f05
commit
bae00f7456
8 changed files with 541 additions and 393 deletions
858
Cargo.lock
generated
858
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
29
Cargo.toml
29
Cargo.toml
|
@ -18,24 +18,22 @@ wasm-opt = ["-Oz", "--enable-mutable-globals"]
|
|||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "3.1.7", features = ["derive"] }
|
||||
vec1 = { version = "1.6.0", features = ["serde"] }
|
||||
itertools = "0.10.0"
|
||||
serde_with = "1.6.2"
|
||||
vec1 = { version = "1.10.1", features = ["serde"] }
|
||||
itertools = "0.10.5"
|
||||
serde_with = "2.1.0"
|
||||
html5ever = "0.26.0"
|
||||
percent-encoding = "2.1.0"
|
||||
url = { version = "2.2.0", features = ["serde"] }
|
||||
percent-encoding = "2.2.0"
|
||||
url = { version = "2.3.1", features = ["serde"] }
|
||||
regex = "1"
|
||||
log = "0.4.14"
|
||||
once_cell = "1.5.2"
|
||||
log = "0.4.17"
|
||||
once_cell = "1.16.0"
|
||||
scraper = "0.13.0"
|
||||
tokio-futures-byteorder = { version = "0.2.0", features = ["futures"] }
|
||||
byteorder = "1.4.2"
|
||||
data-url = "0.1.0"
|
||||
byteorder = "1.4.3"
|
||||
data-url = "0.2.0"
|
||||
mime = { package = "mime_4", version = "0.4.0-a.0" }
|
||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||
serde_json = "1.0"
|
||||
futures = "0.3.12"
|
||||
futures = "0.3.25"
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
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]
|
||||
tokio = { version = "1.1.1", features = ["full"] }
|
||||
env_logger = "0.9.0"
|
||||
reqwest = { version = "0.11.12", features = [
|
||||
clap = { version = "3.2.23", features = ["derive"] }
|
||||
tokio = { version = "1.22.0", features = ["full"] }
|
||||
env_logger = "0.9.3"
|
||||
reqwest = { version = "0.11.13", features = [
|
||||
"json",
|
||||
"cookies",
|
||||
"blocking",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use super::IconInfo;
|
||||
use serde::Serialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::{DeserializeFromStr, SerializeDisplay};
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::HashMap,
|
||||
|
@ -8,7 +9,7 @@ use std::{
|
|||
};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug, Clone, PartialOrd, PartialEq, Ord, Eq)]
|
||||
#[derive(Debug, Clone, PartialOrd, PartialEq, Ord, Eq, SerializeDisplay, DeserializeFromStr)]
|
||||
pub enum IconKind {
|
||||
AppIcon,
|
||||
SiteLogo,
|
||||
|
@ -42,7 +43,6 @@ impl FromStr for IconKind {
|
|||
pub struct Icon {
|
||||
pub url: Url,
|
||||
pub headers: HashMap<String, String>,
|
||||
#[serde(with = "serde_with::rust::display_fromstr")]
|
||||
pub kind: IconKind,
|
||||
#[serde(flatten)]
|
||||
pub info: IconInfo,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::{png::get_png_size, IconSize, IconSizes};
|
||||
use byteorder::{LittleEndian, ReadBytesExt};
|
||||
use byteorder::{LittleEndian, ReadBytesExt as _};
|
||||
use futures::prelude::*;
|
||||
use std::{
|
||||
convert::TryInto,
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
use super::IconSize;
|
||||
use byteorder::BigEndian;
|
||||
use futures::prelude::*;
|
||||
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>(
|
||||
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
|
||||
let page_size = reader.read_u16::<BigEndian>().await? as i64;
|
||||
let page_size = read_u16_be(reader).await? as i64;
|
||||
reader
|
||||
.read_exact(&mut vec![0; (page_size - 2) as usize])
|
||||
.await?;
|
||||
}
|
||||
|
||||
let height = reader.read_u16::<BigEndian>().await?;
|
||||
let width = reader.read_u16::<BigEndian>().await?;
|
||||
let height = read_u16_be(reader).await?;
|
||||
let width = read_u16_be(reader).await?;
|
||||
|
||||
Ok(IconSize::new(width as _, height as _))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use super::IconSize;
|
||||
use byteorder::{BigEndian, ReadBytesExt};
|
||||
use byteorder::{BigEndian, ReadBytesExt as _};
|
||||
use futures::prelude::*;
|
||||
use std::{error::Error, io::Cursor};
|
||||
|
||||
|
|
|
@ -306,13 +306,14 @@ impl Icons {
|
|||
/// Fetch all the icons. Ordered from highest to lowest resolution
|
||||
///
|
||||
/// ```
|
||||
/// # async fn run() {
|
||||
/// let icons = Icons::new();
|
||||
/// icons.load_website("https://github.com").await?;
|
||||
/// async fn run() {
|
||||
/// let mut icons = site_icons::Icons::new();
|
||||
/// icons.load_website("https://github.com").await.unwrap();
|
||||
///
|
||||
/// let entries = icons.entries().await;
|
||||
/// for icon in entries {
|
||||
/// println("{:?}", icon)
|
||||
/// println!("{:?}", icon)
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
pub async fn entries(mut self) -> Vec<Icon> {
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
//! ```rust
|
||||
//! use site_icons::Icons;
|
||||
//!
|
||||
//! async fn run() {
|
||||
//! let mut icons = Icons::new();
|
||||
//! // 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
|
||||
//! let entries = icons.entries().await;
|
||||
|
@ -16,6 +17,7 @@
|
|||
//! for icon in entries {
|
||||
//! println!("{:?}", icon)
|
||||
//! }
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
#[macro_use]
|
||||
|
|
Reference in a new issue