remove send + sync

This commit is contained in:
Sam Denty 2022-07-24 21:14:34 +01:00
parent 05372c8b70
commit f2efe51c22
No known key found for this signature in database
GPG key ID: 7B4EAF7B9E291B79
9 changed files with 43 additions and 29 deletions

43
Cargo.lock generated
View file

@ -177,7 +177,7 @@ dependencies = [
"dtoa-short", "dtoa-short",
"itoa 0.4.8", "itoa 0.4.8",
"matches", "matches",
"phf", "phf 0.8.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"smallvec", "smallvec",
@ -527,9 +527,9 @@ dependencies = [
[[package]] [[package]]
name = "html5ever" name = "html5ever"
version = "0.25.2" version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5c13fb08e5d4dfc151ee5e88bae63f7773d61852f3bdc73c9f4b9e1bde03148" checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7"
dependencies = [ dependencies = [
"log", "log",
"mac", "mac",
@ -727,13 +727,13 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]] [[package]]
name = "markup5ever" name = "markup5ever"
version = "0.10.1" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" checksum = "7a2629bb1404f3d34c2e921f21fd34ba00b206124c81f65c50b43b6aaefeb016"
dependencies = [ dependencies = [
"log", "log",
"phf", "phf 0.10.1",
"phf_codegen", "phf_codegen 0.10.0",
"string_cache", "string_cache",
"string_cache_codegen", "string_cache_codegen",
"tendril", "tendril",
@ -933,6 +933,15 @@ dependencies = [
"proc-macro-hack", "proc-macro-hack",
] ]
[[package]]
name = "phf"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
dependencies = [
"phf_shared 0.10.0",
]
[[package]] [[package]]
name = "phf_codegen" name = "phf_codegen"
version = "0.8.0" version = "0.8.0"
@ -943,6 +952,16 @@ dependencies = [
"phf_shared 0.8.0", "phf_shared 0.8.0",
] ]
[[package]]
name = "phf_codegen"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd"
dependencies = [
"phf_generator 0.10.0",
"phf_shared 0.10.0",
]
[[package]] [[package]]
name = "phf_generator" name = "phf_generator"
version = "0.8.0" version = "0.8.0"
@ -1308,9 +1327,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "scraper" name = "scraper"
version = "0.12.0" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e02aa790c80c2e494130dec6a522033b6a23603ffc06360e9fe6c611ea2c12" checksum = "5684396b456f3eb69ceeb34d1b5cb1a2f6acf7ca4452131efa3ba0ee2c2d0a70"
dependencies = [ dependencies = [
"cssparser", "cssparser",
"ego-tree", "ego-tree",
@ -1357,8 +1376,8 @@ dependencies = [
"fxhash", "fxhash",
"log", "log",
"matches", "matches",
"phf", "phf 0.8.0",
"phf_codegen", "phf_codegen 0.8.0",
"precomputed-hash", "precomputed-hash",
"servo_arc", "servo_arc",
"smallvec", "smallvec",
@ -1494,7 +1513,7 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
[[package]] [[package]]
name = "site_icons" name = "site_icons"
version = "0.1.12" version = "0.1.13"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"clap", "clap",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "site_icons" name = "site_icons"
version = "0.1.12" version = "0.1.13"
authors = ["Sam Denty <sam@samdenty.com>"] authors = ["Sam Denty <sam@samdenty.com>"]
edition = "2018" edition = "2018"
license = "GPL-3.0" license = "GPL-3.0"
@ -22,13 +22,13 @@ clap = { version = "3.1.7", features = ["derive"] }
vec1 = { version = "1.6.0", features = ["serde"] } vec1 = { version = "1.6.0", features = ["serde"] }
itertools = "0.10.0" itertools = "0.10.0"
serde_with = "1.6.2" serde_with = "1.6.2"
html5ever = "0.25.1" html5ever = "0.26.0"
percent-encoding = "2.1.0" percent-encoding = "2.1.0"
url = { version = "2.2.0", features = ["serde"] } url = { version = "2.2.0", features = ["serde"] }
regex = "1" regex = "1"
log = "0.4.14" log = "0.4.14"
once_cell = "1.5.2" once_cell = "1.5.2"
scraper = "0.12.0" scraper = "0.13.0"
tokio-futures-byteorder = { version = "0.2.0", features = ["futures"] } tokio-futures-byteorder = { version = "0.2.0", features = ["futures"] }
byteorder = "1.4.2" byteorder = "1.4.2"
data-url = "0.1.0" data-url = "0.1.0"

View file

@ -33,10 +33,10 @@ impl IconInfo {
pub async fn load( pub async fn load(
url: Url, url: Url,
sizes: Option<String>, sizes: Option<String>,
) -> Result<IconInfo, Box<dyn Error + Send + Sync>> { ) -> Result<IconInfo, Box<dyn Error>> {
let sizes = sizes.as_ref().and_then(|s| IconSizes::from_str(s).ok()); let sizes = sizes.as_ref().and_then(|s| IconSizes::from_str(s).ok());
let (mime, mut body): (_, Box<dyn AsyncRead + Unpin + Send + Sync>) = match url.scheme() { let (mime, mut body): (_, Box<dyn AsyncRead + Unpin>) = match url.scheme() {
"data" => { "data" => {
let url = url.to_string(); let url = url.to_string();
let url = DataUrl::process(&url).map_err(|_| "failed to parse data uri")?; let url = DataUrl::process(&url).map_err(|_| "failed to parse data uri")?;

View file

@ -12,7 +12,7 @@ const INDEX_SIZE: u16 = 16;
pub async fn get_ico_sizes<R: AsyncRead + Unpin>( pub async fn get_ico_sizes<R: AsyncRead + Unpin>(
reader: &mut R, reader: &mut R,
) -> Result<IconSizes, Box<dyn Error + Send + Sync>> { ) -> Result<IconSizes, Box<dyn Error>> {
let mut offset = 0; let mut offset = 0;
let mut header = [0; 6]; let mut header = [0; 6];
reader.read_exact(&mut header).await?; reader.read_exact(&mut header).await?;

View file

@ -6,7 +6,7 @@ use tokio_futures_byteorder::AsyncReadBytesExt;
pub async fn get_jpeg_size<R: AsyncRead + Unpin>( pub async fn get_jpeg_size<R: AsyncRead + Unpin>(
reader: &mut R, reader: &mut R,
) -> Result<IconSize, Box<dyn Error + Send + Sync>> { ) -> Result<IconSize, Box<dyn Error>> {
let mut data = [0; 2]; let mut data = [0; 2];
reader.read_exact(&mut data).await?; reader.read_exact(&mut data).await?;
let data = &mut Cursor::new(data); let data = &mut Cursor::new(data);

View file

@ -88,7 +88,7 @@ fn slice_eq<T: Read + Seek + Unpin>(
cur: &mut T, cur: &mut T,
offset: u64, offset: u64,
slice: &[u8], slice: &[u8],
) -> Result<bool, Box<dyn Error + Send + Sync>> { ) -> Result<bool, Box<dyn Error>> {
cur.seek(SeekFrom::Start(offset))?; cur.seek(SeekFrom::Start(offset))?;
let mut buffer = vec![0; slice.len()]; let mut buffer = vec![0; slice.len()];
cur.read_exact(&mut buffer)?; cur.read_exact(&mut buffer)?;

View file

@ -5,7 +5,7 @@ use std::{error::Error, io::Cursor};
pub async fn get_png_sizes<R: AsyncRead + Unpin>( pub async fn get_png_sizes<R: AsyncRead + Unpin>(
reader: &mut R, reader: &mut R,
) -> Result<IconSize, Box<dyn Error + Send + Sync>> { ) -> Result<IconSize, Box<dyn Error>> {
let mut header = [0; 24]; let mut header = [0; 24];
reader.read_exact(&mut header).await?; reader.read_exact(&mut header).await?;
let header = &mut Cursor::new(header); let header = &mut Cursor::new(header);

View file

@ -19,7 +19,7 @@ pub struct Icons {
Url, Url,
( (
IconKind, IconKind,
Pin<Box<dyn Future<Output = Result<IconInfo, Box<dyn Error + Send + Sync>>> + Send + Sync>>, Pin<Box<dyn Future<Output = Result<IconInfo, Box<dyn Error>>>>>,
), ),
>, >,
} }
@ -28,7 +28,7 @@ fn add_icon_entry(
entries: &mut Vec<Icon>, entries: &mut Vec<Icon>,
url: Url, url: Url,
kind: IconKind, kind: IconKind,
info: Result<IconInfo, Box<dyn Error + Send + Sync>>, info: Result<IconInfo, Box<dyn Error>>,
) { ) {
match info { match info {
Ok(info) => entries.push(Icon { url, kind, info }), Ok(info) => entries.push(Icon { url, kind, info }),

View file

@ -38,18 +38,13 @@ pub use icons::*;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use reqwest::{ use reqwest::{
header::{HeaderMap, HeaderValue, USER_AGENT}, header::{HeaderMap, HeaderValue, USER_AGENT},
redirect::Policy,
Client, Client,
}; };
static CLIENT: Lazy<Client> = Lazy::new(|| { static CLIENT: Lazy<Client> = Lazy::new(|| {
let mut headers = HeaderMap::new(); let mut headers = HeaderMap::new();
headers.insert(USER_AGENT, HeaderValue::from_str("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36").unwrap()); headers.insert(USER_AGENT, HeaderValue::from_str("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36").unwrap());
Client::builder() Client::builder().default_headers(headers).build().unwrap()
.default_headers(headers)
.redirect(Policy::limited(20))
.build()
.unwrap()
}); });
#[cfg(test)] #[cfg(test)]