Send + Sync

This commit is contained in:
Sam Denty 2022-05-03 23:35:09 +01:00
parent e7f181cd5f
commit e82dce00c0
No known key found for this signature in database
GPG key ID: 7B4EAF7B9E291B79
9 changed files with 12 additions and 12 deletions

6
Cargo.lock generated
View file

@ -295,9 +295,9 @@ dependencies = [
[[package]] [[package]]
name = "env_logger" name = "env_logger"
version = "0.8.4" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3" checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
dependencies = [ dependencies = [
"atty", "atty",
"humantime", "humantime",
@ -1494,7 +1494,7 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
[[package]] [[package]]
name = "site_icons" name = "site_icons"
version = "0.1.7" version = "0.1.9"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"clap", "clap",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "site_icons" name = "site_icons"
version = "0.1.8" version = "0.1.9"
authors = ["Sam Denty <sam@samdenty.com>"] authors = ["Sam Denty <sam@samdenty.com>"]
edition = "2018" edition = "2018"
license = "GPL-3.0" license = "GPL-3.0"

View file

@ -30,7 +30,7 @@ pub enum IconInfo {
} }
impl IconInfo { impl IconInfo {
pub async fn load(url: Url, sizes: Option<String>) -> Result<IconInfo, Box<dyn Error>> { pub async fn load(url: Url, sizes: Option<String>) -> Result<IconInfo, Box<dyn Error + Send + Sync>> {
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>) = match url.scheme() { let (mime, mut body): (_, Box<dyn AsyncRead + Unpin>) = match url.scheme() {

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>> { ) -> Result<IconSizes, Box<dyn Error + Send + Sync>> {
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>> { ) -> Result<IconSize, Box<dyn Error + Send + Sync>> {
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>> { ) -> Result<bool, Box<dyn Error + Send + Sync>> {
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>> { ) -> Result<IconSize, Box<dyn Error + Send + Sync>> {
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>>>>>, Pin<Box<dyn Future<Output = Result<IconInfo, Box<dyn Error + Send + Sync>>>>>,
), ),
>, >,
} }
@ -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>>, info: Result<IconInfo, Box<dyn Error + Send + Sync>>,
) { ) {
match info { match info {
Ok(info) => entries.push(Icon { url, kind, info }), Ok(info) => entries.push(Icon { url, kind, info }),

View file

@ -1,4 +1,4 @@
#![feature(async_closure, map_into_keys_values, bool_to_option)] #![feature(async_closure, bool_to_option)]
//! # site_icons //! # site_icons
//! An efficient website icon scraper. //! An efficient website icon scraper.
//! //!