From 7d540863a467b04fbaf44dcdcdc1f2b9628fcaf0 Mon Sep 17 00:00:00 2001 From: Noel Date: Sun, 4 Aug 2024 15:29:35 -0700 Subject: [PATCH] [fs] breaking: remove `async_std` crate and remove double allocation in `resolver` field Since both and allocate memory on the heap, we don't need both ; works as well. --- crates/fs/Cargo.toml | 2 -- crates/fs/src/service.rs | 11 +++-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/crates/fs/Cargo.toml b/crates/fs/Cargo.toml index fcbcea0..adc6ea5 100644 --- a/crates/fs/Cargo.toml +++ b/crates/fs/Cargo.toml @@ -32,14 +32,12 @@ rust-version.workspace = true file-format = ["dep:infer", "dep:file-format"] serde_json = ["dep:serde_json"] serde_yaml = ["dep:serde_yaml"] -async-std = ["dep:async-std"] default = ["file-format", "serde_json"] tracing = ["dep:tracing"] serde = ["dep:serde"] log = ["dep:log"] [dependencies] -async-std = { version = "1.12.0", optional = true } async-trait = "0.1.80" bytes = "1.6.0" dirs = "5.0.1" diff --git a/crates/fs/src/service.rs b/crates/fs/src/service.rs index 081b496..9a95e72 100644 --- a/crates/fs/src/service.rs +++ b/crates/fs/src/service.rs @@ -30,13 +30,8 @@ use std::{ sync::Arc, time::SystemTime, }; - -#[cfg(not(feature = "async_std"))] use tokio::{fs, io::*}; -#[cfg(feature = "async_std")] -use async_std::{fs, io::*}; - #[cfg(feature = "tracing")] use tracing::instrument; @@ -44,7 +39,7 @@ use tracing::instrument; /// local filesystem. #[derive(Clone)] pub struct StorageService { - resolver: Arc>, + resolver: Arc, config: Config, } @@ -57,14 +52,14 @@ impl StorageService { /// Creates a new [`StorageService`] instance with a provided configuration object. pub fn with_config(config: Config) -> StorageService { StorageService { - resolver: Arc::new(Box::new(default_resolver)), + resolver: Arc::new(default_resolver), config, } } /// Updates the given [`ContentTypeResolver`] to something else. pub fn with_resolver(mut self, resolver: R) -> StorageService { - self.resolver = Arc::new(Box::new(resolver)); + self.resolver = Arc::new(resolver); self }