This is an automated email from the ASF dual-hosted git repository. tison pushed a commit to branch bb8-to-fastpool in repository https://gitbox.apache.org/repos/asf/opendal.git
commit 052cb4cca1cf49a0577dcfbba3c641fe6637a704 Author: tison <[email protected]> AuthorDate: Tue Nov 25 19:58:07 2025 +0800 run format Signed-off-by: tison <[email protected]> --- core/benches/vs_fs/src/main.rs | 11 +- core/src/blocking/operator.rs | 8 +- core/src/blocking/write/writer.rs | 2 +- core/src/docs/concepts.rs | 4 +- core/src/layers/http_client.rs | 12 ++- core/src/layers/retry.rs | 28 ++--- core/src/layers/tail_cut.rs | 13 ++- core/src/lib.rs | 10 +- core/src/raw/azure.rs | 14 +-- core/src/raw/http_util/bytes_range.rs | 22 ++-- core/src/raw/ops.rs | 5 +- core/src/raw/path.rs | 4 +- core/src/raw/serde_util.rs | 58 +++++----- core/src/raw/time.rs | 14 ++- core/src/services/aliyun_drive/lister.rs | 3 +- core/src/services/azblob/core.rs | 9 +- core/src/services/azblob/error.rs | 11 +- core/src/services/azdls/backend.rs | 3 +- core/src/services/azdls/config.rs | 8 +- core/src/services/azdls/error.rs | 11 +- core/src/services/azdls/lister.rs | 19 ++-- core/src/services/azfile/backend.rs | 3 +- core/src/services/azfile/config.rs | 8 +- core/src/services/azfile/error.rs | 11 +- core/src/services/b2/config.rs | 8 +- core/src/services/cacache/deleter.rs | 3 +- core/src/services/cacache/writer.rs | 3 +- core/src/services/cloudflare_kv/core.rs | 8 +- core/src/services/cloudflare_kv/lister.rs | 3 +- core/src/services/cloudflare_kv/model.rs | 3 +- core/src/services/cloudflare_kv/writer.rs | 3 +- core/src/services/compfs/core.rs | 4 +- core/src/services/cos/core.rs | 7 +- core/src/services/dashmap/deleter.rs | 4 +- core/src/services/dashmap/lister.rs | 9 +- core/src/services/dashmap/writer.rs | 15 ++- core/src/services/dropbox/writer.rs | 3 +- core/src/services/etcd/core.rs | 26 ++--- core/src/services/etcd/error.rs | 3 +- core/src/services/etcd/lister.rs | 4 +- core/src/services/ftp/backend.rs | 11 +- core/src/services/ftp/core.rs | 9 +- core/src/services/ghac/config.rs | 8 +- core/src/services/http/config.rs | 11 +- core/src/services/huggingface/config.rs | 8 +- core/src/services/huggingface/core.rs | 11 +- core/src/services/ipmfs/builder.rs | 2 +- core/src/services/lakefs/config.rs | 8 +- core/src/services/lakefs/lister.rs | 3 +- core/src/services/memcached/core.rs | 5 +- core/src/services/mini_moka/config.rs | 8 +- core/src/services/mini_moka/writer.rs | 6 +- core/src/services/moka/backend.rs | 6 +- core/src/services/moka/mod.rs | 3 +- core/src/services/moka/writer.rs | 3 +- core/src/services/obs/core.rs | 7 +- core/src/services/opfs/core.rs | 5 +- core/src/services/opfs/error.rs | 3 +- core/src/services/opfs/utils.rs | 11 +- core/src/services/oss/core.rs | 43 ++++---- core/src/services/pcloud/config.rs | 8 +- core/src/services/redis/core.rs | 7 +- core/src/services/s3/core.rs | 153 ++++++++++++--------------- core/src/services/sftp/config.rs | 13 +-- core/src/services/sftp/core.rs | 43 ++++---- core/src/services/sqlite/backend.rs | 3 +- core/src/services/sqlite/core.rs | 3 +- core/src/services/sqlite/deleter.rs | 4 +- core/src/services/sqlite/writer.rs | 4 +- core/src/services/swift/config.rs | 8 +- core/src/services/swift/core.rs | 39 +++---- core/src/services/vercel_artifacts/config.rs | 8 +- core/src/services/vercel_blob/deleter.rs | 3 +- core/src/services/webdav/config.rs | 19 ++-- core/src/services/yandex_disk/config.rs | 8 +- core/src/types/buffer.rs | 18 ++-- core/src/types/builder.rs | 8 +- core/src/types/delete/deleter.rs | 2 +- core/src/types/metadata.rs | 3 +- core/src/types/operator/builder.rs | 18 ++-- core/src/types/operator/mod.rs | 7 +- core/src/types/operator/operator.rs | 17 +-- core/src/types/operator/operator_futures.rs | 3 +- core/src/types/operator/registry.rs | 14 ++- core/src/types/operator/uri.rs | 12 ++- core/src/types/options.rs | 4 +- rustfmt.toml | 1 - 87 files changed, 504 insertions(+), 494 deletions(-) diff --git a/core/benches/vs_fs/src/main.rs b/core/benches/vs_fs/src/main.rs index 22e13d9e7..1f471663b 100644 --- a/core/benches/vs_fs/src/main.rs +++ b/core/benches/vs_fs/src/main.rs @@ -56,13 +56,10 @@ fn bench_vs_fs(c: &mut Criterion) { let path = prepare(); b.iter(|| { let _ = op - .read_options( - &path, - options::ReadOptions { - range: (0..16 * 1024 * 1024).into(), - ..Default::default() - }, - ) + .read_options(&path, options::ReadOptions { + range: (0..16 * 1024 * 1024).into(), + ..Default::default() + }) .unwrap(); }); }); diff --git a/core/src/blocking/operator.rs b/core/src/blocking/operator.rs index 037b65a19..a596c1248 100644 --- a/core/src/blocking/operator.rs +++ b/core/src/blocking/operator.rs @@ -199,9 +199,9 @@ impl Operator { /// ``` /// # use anyhow::Result; /// # use futures::io; - /// use opendal::blocking; /// # use opendal::blocking::Operator; /// use opendal::ErrorKind; + /// use opendal::blocking; /// # /// # fn test(op: blocking::Operator) -> Result<()> { /// if let Err(e) = op.stat("test") { @@ -598,9 +598,9 @@ impl Operator { /// /// ```no_run /// # use anyhow::Result; + /// use opendal::EntryMode; /// use opendal::blocking; /// use opendal::blocking::Operator; - /// use opendal::EntryMode; /// # fn test(op: blocking::Operator) -> Result<()> { /// let mut entries = op.list("path/to/dir/")?; /// for entry in entries { @@ -656,9 +656,9 @@ impl Operator { /// # use anyhow::Result; /// # use futures::io; /// use futures::TryStreamExt; + /// use opendal::EntryMode; /// use opendal::blocking; /// use opendal::blocking::Operator; - /// use opendal::EntryMode; /// # fn test(op: blocking::Operator) -> Result<()> { /// let mut ds = op.lister("path/to/dir/")?; /// for de in ds { @@ -701,9 +701,9 @@ impl Operator { /// ``` /// # use std::sync::Arc; /// # use anyhow::Result; + /// use opendal::ErrorKind; /// use opendal::blocking; /// use opendal::blocking::Operator; - /// use opendal::ErrorKind; /// /// # fn test(op: blocking::Operator) -> Result<()> { /// op.check()?; diff --git a/core/src/blocking/write/writer.rs b/core/src/blocking/write/writer.rs index cdb617b49..e1e07dfe5 100644 --- a/core/src/blocking/write/writer.rs +++ b/core/src/blocking/write/writer.rs @@ -49,9 +49,9 @@ impl Writer { /// /// ``` /// use bytes::Bytes; + /// use opendal::Result; /// use opendal::blocking; /// use opendal::blocking::Operator; - /// use opendal::Result; /// /// fn test(op: blocking::Operator) -> Result<()> { /// let mut w = op.writer("hello.txt")?; diff --git a/core/src/docs/concepts.rs b/core/src/docs/concepts.rs index e512ba603..4fe0c67de 100644 --- a/core/src/docs/concepts.rs +++ b/core/src/docs/concepts.rs @@ -79,8 +79,8 @@ //! //! ```no_run //! # use opendal::Result; -//! use opendal::services::S3; //! use opendal::Operator; +//! use opendal::services::S3; //! //! # fn test() -> Result<()> { //! let mut builder = S3::default(); @@ -117,8 +117,8 @@ //! //! ```no_run //! # use opendal::Result; -//! use opendal::services::S3; //! use opendal::Operator; +//! use opendal::services::S3; //! //! # async fn test() -> Result<()> { //! let mut builder = S3::default(); diff --git a/core/src/layers/http_client.rs b/core/src/layers/http_client.rs index 8f8d2632d..84e31ef63 100644 --- a/core/src/layers/http_client.rs +++ b/core/src/layers/http_client.rs @@ -28,11 +28,11 @@ use crate::*; /// # Examples /// /// ```no_run -/// use opendal::layers::HttpClientLayer; -/// use opendal::services; /// use opendal::Operator; /// use opendal::Result; +/// use opendal::layers::HttpClientLayer; /// use opendal::raw::HttpClient; +/// use opendal::services; /// /// # fn main() -> Result<()> { /// // Create a custom HTTP client @@ -48,10 +48,12 @@ use crate::*; /// # Custom HTTP Client Implementation /// /// ```no_run -/// use opendal::raw::{HttpFetch, HttpBody}; +/// use http::Request; +/// use http::Response; /// use opendal::Buffer; -/// use http::{Request, Response}; /// use opendal::Result; +/// use opendal::raw::HttpBody; +/// use opendal::raw::HttpFetch; /// /// struct CustomHttpClient { /// // Your custom HTTP client fields @@ -79,9 +81,9 @@ impl HttpClientLayer { /// # Examples /// /// ```no_run + /// use opendal::Result; /// use opendal::layers::HttpClientLayer; /// use opendal::raw::HttpClient; - /// use opendal::Result; /// /// # fn main() -> Result<()> { /// let client = HttpClient::new()?; diff --git a/core/src/layers/retry.rs b/core/src/layers/retry.rs index 59a63830f..b42b08d97 100644 --- a/core/src/layers/retry.rs +++ b/core/src/layers/retry.rs @@ -143,9 +143,9 @@ impl RetryLayer { /// /// ```no_run /// use anyhow::Result; + /// use opendal::Operator; /// use opendal::layers::RetryLayer; /// use opendal::services; - /// use opendal::Operator; /// /// let _ = Operator::new(services::Memory::default()) /// .expect("must init") @@ -160,9 +160,9 @@ impl<I: RetryInterceptor> RetryLayer<I> { /// Set the retry interceptor as new notify. /// /// ```no_run + /// use opendal::Operator; /// use opendal::layers::RetryLayer; /// use opendal::services; - /// use opendal::Operator; /// /// fn notify(_err: &opendal::Error, _dur: std::time::Duration) {} /// @@ -660,24 +660,18 @@ mod tests { } async fn read(&self, _: &str, args: OpRead) -> Result<(RpRead, Self::Reader)> { - Ok(( - RpRead::new(), - MockReader { - buf: Bytes::from("Hello, World!").into(), - range: args.range(), - attempt: self.attempt.clone(), - }, - )) + Ok((RpRead::new(), MockReader { + buf: Bytes::from("Hello, World!").into(), + range: args.range(), + attempt: self.attempt.clone(), + })) } async fn delete(&self) -> Result<(RpDelete, Self::Deleter)> { - Ok(( - RpDelete::default(), - MockDeleter { - size: 0, - attempt: self.attempt.clone(), - }, - )) + Ok((RpDelete::default(), MockDeleter { + size: 0, + attempt: self.attempt.clone(), + })) } async fn write(&self, _: &str, _: OpWrite) -> Result<(RpWrite, Self::Writer)> { diff --git a/core/src/layers/tail_cut.rs b/core/src/layers/tail_cut.rs index 42a071c60..5ebddbbc7 100644 --- a/core/src/layers/tail_cut.rs +++ b/core/src/layers/tail_cut.rs @@ -18,7 +18,9 @@ use std::fmt::Debug; use std::fmt::Formatter; use std::sync::Arc; -use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; +use std::sync::atomic::AtomicU64; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; use std::time::Duration; use std::time::Instant; @@ -33,8 +35,9 @@ use crate::*; /// # Examples /// /// ```no_run -/// use opendal::layers::TailCutLayer; /// use std::time::Duration; +/// +/// use opendal::layers::TailCutLayer; /// # use opendal::services; /// # use opendal::Operator; /// # use opendal::Result; @@ -176,8 +179,9 @@ impl TailCutLayerBuilder { /// # Examples /// /// ```no_run - /// use opendal::layers::TailCutLayer; /// use std::time::Duration; + /// + /// use opendal::layers::TailCutLayer; /// # use opendal::services; /// # use opendal::Operator; /// # use opendal::Result; @@ -237,8 +241,9 @@ struct TailCutConfig { /// # Examples /// /// ```no_run -/// use opendal::layers::TailCutLayer; /// use std::time::Duration; +/// +/// use opendal::layers::TailCutLayer; /// # use opendal::services; /// # use opendal::Operator; /// # use opendal::Result; diff --git a/core/src/lib.rs b/core/src/lib.rs index 89177dbbb..73d751464 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -41,9 +41,9 @@ //! Let's take [`services::S3`] as an example: //! //! ```no_run -//! use opendal::services; //! use opendal::Operator; //! use opendal::Result; +//! use opendal::services; //! //! fn main() -> Result<()> { //! // Pick a builder and configure it. @@ -64,10 +64,10 @@ //! every operation that OpenDAL performs. //! //! ```no_run -//! use opendal::layers::LoggingLayer; -//! use opendal::services; //! use opendal::Operator; //! use opendal::Result; +//! use opendal::layers::LoggingLayer; +//! use opendal::services; //! //! #[tokio::main] //! async fn main() -> Result<()> { @@ -102,11 +102,11 @@ //! into [`futures::AsyncRead`] or [`futures::Stream`] for broader ecosystem compatibility. //! //! ```no_run +//! use opendal::Operator; +//! use opendal::Result; //! use opendal::layers::LoggingLayer; //! use opendal::options; //! use opendal::services; -//! use opendal::Operator; -//! use opendal::Result; //! //! #[tokio::main] //! async fn main() -> Result<()> { diff --git a/core/src/raw/azure.rs b/core/src/raw/azure.rs index c9ef55bbc..3645a4dae 100644 --- a/core/src/raw/azure.rs +++ b/core/src/raw/azure.rs @@ -25,9 +25,12 @@ use std::collections::HashMap; use http::Uri; use http::response::Parts; -use reqsign::{AzureStorageConfig, AzureStorageCredential}; +use reqsign::AzureStorageConfig; +use reqsign::AzureStorageCredential; -use crate::{Error, ErrorKind, Result}; +use crate::Error; +use crate::ErrorKind; +use crate::Result; /// Parses an [Azure connection string][1] into a configuration object. /// @@ -329,12 +332,11 @@ mod tests { use http::Uri; use reqsign::AzureStorageConfig; + use super::AzureStorageService; + use super::azure_account_name_from_endpoint; + use super::azure_config_from_connection_string; use crate::raw::azure::censor_sas_uri; - use super::{ - AzureStorageService, azure_account_name_from_endpoint, azure_config_from_connection_string, - }; - #[test] fn test_azure_config_from_connection_string() { #[allow(unused_mut)] diff --git a/core/src/raw/http_util/bytes_range.rs b/core/src/raw/http_util/bytes_range.rs index 23b4a3d9b..96bbb806e 100644 --- a/core/src/raw/http_util/bytes_range.rs +++ b/core/src/raw/http_util/bytes_range.rs @@ -95,24 +95,18 @@ impl BytesRange { /// Convert bytes range into rust range. pub fn to_range(&self) -> impl RangeBounds<u64> { - ( - Bound::Included(self.0), - match self.1 { - Some(size) => Bound::Excluded(self.0 + size), - None => Bound::Unbounded, - }, - ) + (Bound::Included(self.0), match self.1 { + Some(size) => Bound::Excluded(self.0 + size), + None => Bound::Unbounded, + }) } /// Convert bytes range into rust range with usize. pub(crate) fn to_range_as_usize(self) -> impl RangeBounds<usize> { - ( - Bound::Included(self.0 as usize), - match self.1 { - Some(size) => Bound::Excluded((self.0 + size) as usize), - None => Bound::Unbounded, - }, - ) + (Bound::Included(self.0 as usize), match self.1 { + Some(size) => Bound::Excluded((self.0 + size) as usize), + None => Bound::Unbounded, + }) } } diff --git a/core/src/raw/ops.rs b/core/src/raw/ops.rs index abd89be9e..7af9d86da 100644 --- a/core/src/raw/ops.rs +++ b/core/src/raw/ops.rs @@ -19,11 +19,12 @@ //! //! By using ops, users can add more context for operation. -use crate::options; -use crate::raw::*; use std::collections::HashMap; use std::time::Duration; +use crate::options; +use crate::raw::*; + /// Args for `create` operation. /// /// The path must be normalized. diff --git a/core/src/raw/path.rs b/core/src/raw/path.rs index 55733f47c..5b71d03b0 100644 --- a/core/src/raw/path.rs +++ b/core/src/raw/path.rs @@ -15,8 +15,10 @@ // specific language governing permissions and limitations // under the License. +use std::hash::BuildHasher; +use std::hash::Hasher; + use crate::*; -use std::hash::{BuildHasher, Hasher}; /// build_abs_path will build an absolute path with root. /// diff --git a/core/src/raw/serde_util.rs b/core/src/raw/serde_util.rs index 3c5ded9b8..3760d5488 100644 --- a/core/src/raw/serde_util.rs +++ b/core/src/raw/serde_util.rs @@ -375,31 +375,28 @@ mod tests { .collect(); let output = TestConfig::deserialize(ConfigDeserializer::new(map)).unwrap(); - assert_eq!( - output, - TestConfig { - bool_value: true, - bool_option_value_none: None, - bool_option_value_some: Some(false), - bool_value_with_on: true, - bool_value_with_off: false, - string_value: "hello".to_string(), - string_option_value_none: None, - string_option_value_some: Some("hello".to_string()), - u8_value: 8, - u16_value: 16, - u32_value: 32, - u64_value: 64, - i8_value: -8, - i16_value: 16, - i32_value: -32, - i64_value: 64, - vec_value: vec!["hello".to_string()], - vec_value_two: vec!["hello".to_string(), "world".to_string()], - vec_none: None, - vec_empty: vec![], - } - ); + assert_eq!(output, TestConfig { + bool_value: true, + bool_option_value_none: None, + bool_option_value_some: Some(false), + bool_value_with_on: true, + bool_value_with_off: false, + string_value: "hello".to_string(), + string_option_value_none: None, + string_option_value_some: Some("hello".to_string()), + u8_value: 8, + u16_value: 16, + u32_value: 32, + u64_value: 64, + i8_value: -8, + i16_value: 16, + i32_value: -32, + i64_value: 64, + vec_value: vec!["hello".to_string()], + vec_value_two: vec!["hello".to_string(), "world".to_string()], + vec_none: None, + vec_empty: vec![], + }); } #[test] @@ -412,12 +409,9 @@ mod tests { .collect(); let output = TestConfig::deserialize(ConfigDeserializer::new(map)).unwrap(); - assert_eq!( - output, - TestConfig { - bool_value: true, - ..TestConfig::default() - } - ); + assert_eq!(output, TestConfig { + bool_value: true, + ..TestConfig::default() + }); } } diff --git a/core/src/raw/time.rs b/core/src/raw/time.rs index 9d67931b3..1fbbbc4e4 100644 --- a/core/src/raw/time.rs +++ b/core/src/raw/time.rs @@ -17,12 +17,18 @@ //! Time related utils. -use crate::*; -use jiff::SignedDuration; use std::fmt; -use std::ops::{Add, AddAssign, Sub, SubAssign}; +use std::ops::Add; +use std::ops::AddAssign; +use std::ops::Sub; +use std::ops::SubAssign; use std::str::FromStr; -use std::time::{Duration, SystemTime}; +use std::time::Duration; +use std::time::SystemTime; + +use jiff::SignedDuration; + +use crate::*; /// An instant in time represented as the number of nanoseconds since the Unix epoch. #[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/core/src/services/aliyun_drive/lister.rs b/core/src/services/aliyun_drive/lister.rs index 8fa9e795a..1b929475f 100644 --- a/core/src/services/aliyun_drive/lister.rs +++ b/core/src/services/aliyun_drive/lister.rs @@ -17,6 +17,8 @@ use std::sync::Arc; +use bytes::Buf; + use self::oio::Entry; use super::core::AliyunDriveCore; use super::core::AliyunDriveFileList; @@ -26,7 +28,6 @@ use crate::ErrorKind; use crate::Metadata; use crate::Result; use crate::raw::*; -use bytes::Buf; pub struct AliyunDriveLister { core: Arc<AliyunDriveCore>, diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs index fe533807b..d1293e70d 100644 --- a/core/src/services/azblob/core.rs +++ b/core/src/services/azblob/core.rs @@ -921,9 +921,10 @@ mod tests { let out: PutBlockListRequest = de::from_reader(Bytes::from(bs).reader()).expect("must success"); - assert_eq!( - out.latest, - vec!["1".to_string(), "2".to_string(), "3".to_string()] - ); + assert_eq!(out.latest, vec![ + "1".to_string(), + "2".to_string(), + "3".to_string() + ]); } } diff --git a/core/src/services/azblob/error.rs b/core/src/services/azblob/error.rs index 0d26b8cd5..f8df7536e 100644 --- a/core/src/services/azblob/error.rs +++ b/core/src/services/azblob/error.rs @@ -86,13 +86,10 @@ pub(super) fn parse_error(resp: Response<Buffer>) -> Error { if message.is_empty() { if let Some(v) = parts.headers.get("x-ms-error-code") { if let Ok(code) = v.to_str() { - message = format!( - "{:?}", - AzblobError { - code: code.to_string(), - ..Default::default() - } - ) + message = format!("{:?}", AzblobError { + code: code.to_string(), + ..Default::default() + }) } } } diff --git a/core/src/services/azdls/backend.rs b/core/src/services/azdls/backend.rs index 989a16b36..4209eedaf 100644 --- a/core/src/services/azdls/backend.rs +++ b/core/src/services/azdls/backend.rs @@ -214,7 +214,8 @@ impl AzdlsBuilder { /// use opendal::Builder; /// use opendal::services::Azdls; /// - /// let conn_str = "AccountName=example;DefaultEndpointsProtocol=https;EndpointSuffix=core.windows.net"; + /// let conn_str = + /// "AccountName=example;DefaultEndpointsProtocol=https;EndpointSuffix=core.windows.net"; /// /// let mut config = Azdls::from_connection_string(&conn_str) /// .unwrap() diff --git a/core/src/services/azdls/config.rs b/core/src/services/azdls/config.rs index c4e5a7643..61b82b0f5 100644 --- a/core/src/services/azdls/config.rs +++ b/core/src/services/azdls/config.rs @@ -155,10 +155,10 @@ mod tests { #[test] fn from_uri_accepts_filesystem_from_query() { - let uri = OperatorUri::new( - "azdls://account.dfs.core.windows.net", - vec![("filesystem".to_string(), "logs".to_string())], - ) + let uri = OperatorUri::new("azdls://account.dfs.core.windows.net", vec![( + "filesystem".to_string(), + "logs".to_string(), + )]) .unwrap(); let cfg = AzdlsConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/azdls/error.rs b/core/src/services/azdls/error.rs index 83770195e..f7d22b584 100644 --- a/core/src/services/azdls/error.rs +++ b/core/src/services/azdls/error.rs @@ -84,13 +84,10 @@ pub(super) fn parse_error(resp: Response<Buffer>) -> Error { if message.is_empty() { if let Some(v) = parts.headers.get("x-ms-error-code") { if let Ok(code) = v.to_str() { - message = format!( - "{:?}", - AzdlsError { - code: code.to_string(), - ..Default::default() - } - ) + message = format!("{:?}", AzdlsError { + code: code.to_string(), + ..Default::default() + }) } } } diff --git a/core/src/services/azdls/lister.rs b/core/src/services/azdls/lister.rs index 2e5744a81..97aee6b66 100644 --- a/core/src/services/azdls/lister.rs +++ b/core/src/services/azdls/lister.rs @@ -150,16 +150,13 @@ mod tests { let out: Output = de::from_slice(&bs).expect("must success"); println!("{out:?}"); - assert_eq!( - out.paths[0], - Path { - content_length: "1977097".to_string(), - etag: "0x8DACF9B0061305F".to_string(), - is_directory: "".to_string(), - last_modified: "Sat, 26 Nov 2022 10:43:05 GMT".to_string(), - name: "c3b3ef48-7783-4946-81bc-dc07e1728878/d4ea21d7-a533-4011-8b1f-d0e566d63725" - .to_string() - } - ); + assert_eq!(out.paths[0], Path { + content_length: "1977097".to_string(), + etag: "0x8DACF9B0061305F".to_string(), + is_directory: "".to_string(), + last_modified: "Sat, 26 Nov 2022 10:43:05 GMT".to_string(), + name: "c3b3ef48-7783-4946-81bc-dc07e1728878/d4ea21d7-a533-4011-8b1f-d0e566d63725" + .to_string() + }); } } diff --git a/core/src/services/azfile/backend.rs b/core/src/services/azfile/backend.rs index 45c02b663..96a821160 100644 --- a/core/src/services/azfile/backend.rs +++ b/core/src/services/azfile/backend.rs @@ -149,7 +149,8 @@ impl AzfileBuilder { /// use opendal::Builder; /// use opendal::services::Azfile; /// - /// let conn_str = "AccountName=example;DefaultEndpointsProtocol=https;EndpointSuffix=core.windows.net"; + /// let conn_str = + /// "AccountName=example;DefaultEndpointsProtocol=https;EndpointSuffix=core.windows.net"; /// /// let mut config = Azfile::from_connection_string(&conn_str) /// .unwrap() diff --git a/core/src/services/azfile/config.rs b/core/src/services/azfile/config.rs index ed7bd1ef7..baade64ee 100644 --- a/core/src/services/azfile/config.rs +++ b/core/src/services/azfile/config.rs @@ -135,10 +135,10 @@ mod tests { #[test] fn from_uri_accepts_share_from_query() { - let uri = OperatorUri::new( - "azfile://account.file.core.windows.net", - vec![("share_name".to_string(), "data".to_string())], - ) + let uri = OperatorUri::new("azfile://account.file.core.windows.net", vec![( + "share_name".to_string(), + "data".to_string(), + )]) .unwrap(); let cfg = AzfileConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/azfile/error.rs b/core/src/services/azfile/error.rs index ec0bd6970..9c15d146c 100644 --- a/core/src/services/azfile/error.rs +++ b/core/src/services/azfile/error.rs @@ -85,13 +85,10 @@ pub(super) fn parse_error(resp: Response<Buffer>) -> Error { if message.is_empty() { if let Some(v) = parts.headers.get("x-ms-error-code") { if let Ok(code) = v.to_str() { - message = format!( - "{:?}", - AzfileError { - code: code.to_string(), - ..Default::default() - } - ) + message = format!("{:?}", AzfileError { + code: code.to_string(), + ..Default::default() + }) } } } diff --git a/core/src/services/b2/config.rs b/core/src/services/b2/config.rs index 7910a4e99..667091030 100644 --- a/core/src/services/b2/config.rs +++ b/core/src/services/b2/config.rs @@ -96,10 +96,10 @@ mod tests { #[test] fn from_uri_extracts_bucket_and_root() { - let uri = OperatorUri::new( - "b2://example-bucket/path/to/root", - vec![("bucket_id".to_string(), "bucket-id".to_string())], - ) + let uri = OperatorUri::new("b2://example-bucket/path/to/root", vec![( + "bucket_id".to_string(), + "bucket-id".to_string(), + )]) .unwrap(); let cfg = B2Config::from_uri(&uri).unwrap(); diff --git a/core/src/services/cacache/deleter.rs b/core/src/services/cacache/deleter.rs index 225fbf207..ccf8d4be6 100644 --- a/core/src/services/cacache/deleter.rs +++ b/core/src/services/cacache/deleter.rs @@ -17,11 +17,10 @@ use std::sync::Arc; +use super::core::CacacheCore; use crate::raw::*; use crate::*; -use super::core::CacacheCore; - pub struct CacacheDeleter { core: Arc<CacacheCore>, } diff --git a/core/src/services/cacache/writer.rs b/core/src/services/cacache/writer.rs index e82e74aae..401650e5b 100644 --- a/core/src/services/cacache/writer.rs +++ b/core/src/services/cacache/writer.rs @@ -17,11 +17,10 @@ use std::sync::Arc; +use super::core::CacacheCore; use crate::raw::*; use crate::*; -use super::core::CacacheCore; - pub struct CacacheWriter { core: Arc<CacacheCore>, path: String, diff --git a/core/src/services/cloudflare_kv/core.rs b/core/src/services/cloudflare_kv/core.rs index 13797b587..699dfa967 100644 --- a/core/src/services/cloudflare_kv/core.rs +++ b/core/src/services/cloudflare_kv/core.rs @@ -24,13 +24,17 @@ use http::header; use http::request; use serde_json::json; +use crate::Buffer; +use crate::Result; +use crate::raw::AccessorInfo; +use crate::raw::FormDataPart; +use crate::raw::Multipart; use crate::raw::Operation; use crate::raw::QueryPairsWriter; use crate::raw::new_json_serialize_error; +use crate::raw::new_request_build_error; use crate::raw::percent_encode_path; -use crate::raw::{AccessorInfo, FormDataPart, Multipart, new_request_build_error}; use crate::services::cloudflare_kv::model::CfKvMetadata; -use crate::{Buffer, Result}; #[derive(Debug, Clone)] pub struct CloudflareKvCore { diff --git a/core/src/services/cloudflare_kv/lister.rs b/core/src/services/cloudflare_kv/lister.rs index 1eeca9906..43b6d566e 100644 --- a/core/src/services/cloudflare_kv/lister.rs +++ b/core/src/services/cloudflare_kv/lister.rs @@ -22,7 +22,8 @@ use bytes::Buf; use super::core::CloudflareKvCore; use super::error::parse_error; use crate::raw::*; -use crate::services::cloudflare_kv::model::{CfKvListKey, CfKvListResponse}; +use crate::services::cloudflare_kv::model::CfKvListKey; +use crate::services::cloudflare_kv::model::CfKvListResponse; use crate::*; pub struct CloudflareKvLister { diff --git a/core/src/services/cloudflare_kv/model.rs b/core/src/services/cloudflare_kv/model.rs index 390f11d82..5f56d6450 100644 --- a/core/src/services/cloudflare_kv/model.rs +++ b/core/src/services/cloudflare_kv/model.rs @@ -17,7 +17,8 @@ // use std::collections::HashMap; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; +use serde::Serialize; #[derive(Debug, Deserialize)] pub struct CfKvResponse { diff --git a/core/src/services/cloudflare_kv/writer.rs b/core/src/services/cloudflare_kv/writer.rs index c644611bd..e9a2cd8ec 100644 --- a/core/src/services/cloudflare_kv/writer.rs +++ b/core/src/services/cloudflare_kv/writer.rs @@ -17,12 +17,13 @@ use std::sync::Arc; +use http::StatusCode; + use super::core::CloudflareKvCore; use super::error::parse_error; use crate::raw::*; use crate::services::cloudflare_kv::model::CfKvMetadata; use crate::*; -use http::StatusCode; pub struct CloudflareWriter { core: Arc<CloudflareKvCore>, diff --git a/core/src/services/compfs/core.rs b/core/src/services/compfs/core.rs index 6151ac8e7..5998ebc3e 100644 --- a/core/src/services/compfs/core.rs +++ b/core/src/services/compfs/core.rs @@ -19,7 +19,9 @@ use std::future::Future; use std::path::PathBuf; use std::sync::Arc; -use compio::buf::{IoBuf, IoBuffer, IoVectoredBuf}; +use compio::buf::IoBuf; +use compio::buf::IoBuffer; +use compio::buf::IoVectoredBuf; use compio::dispatcher::Dispatcher; use crate::raw::*; diff --git a/core/src/services/cos/core.rs b/core/src/services/cos/core.rs index cb3c75b38..346627f0c 100644 --- a/core/src/services/cos/core.rs +++ b/core/src/services/cos/core.rs @@ -739,10 +739,9 @@ mod tests { .collect::<Vec<String>>(), ["obj002", "obj003"], ); - assert_eq!( - out.contents.iter().map(|v| v.size).collect::<Vec<u64>>(), - [9, 10], - ); + assert_eq!(out.contents.iter().map(|v| v.size).collect::<Vec<u64>>(), [ + 9, 10 + ],); assert_eq!( out.common_prefixes .iter() diff --git a/core/src/services/dashmap/deleter.rs b/core/src/services/dashmap/deleter.rs index 0f4e10e50..f1990bff0 100644 --- a/core/src/services/dashmap/deleter.rs +++ b/core/src/services/dashmap/deleter.rs @@ -18,7 +18,9 @@ use std::sync::Arc; use super::core::DashmapCore; -use crate::raw::{OpDelete, build_abs_path, oio}; +use crate::raw::OpDelete; +use crate::raw::build_abs_path; +use crate::raw::oio; use crate::*; pub struct DashmapDeleter { diff --git a/core/src/services/dashmap/lister.rs b/core/src/services/dashmap/lister.rs index e276ac3d1..df9d5b35d 100644 --- a/core/src/services/dashmap/lister.rs +++ b/core/src/services/dashmap/lister.rs @@ -15,12 +15,15 @@ // specific language governing permissions and limitations // under the License. +use std::sync::Arc; +use std::vec::IntoIter; + use super::core::DashmapCore; +use crate::raw::build_abs_path; +use crate::raw::build_rel_path; +use crate::raw::oio; use crate::raw::oio::Entry; -use crate::raw::{build_abs_path, build_rel_path, oio}; use crate::*; -use std::sync::Arc; -use std::vec::IntoIter; pub struct DashmapLister { root: String, diff --git a/core/src/services/dashmap/writer.rs b/core/src/services/dashmap/writer.rs index 54efe86cb..494bf9dba 100644 --- a/core/src/services/dashmap/writer.rs +++ b/core/src/services/dashmap/writer.rs @@ -20,7 +20,9 @@ use std::time::SystemTime; use super::core::DashmapCore; use super::core::DashmapValue; -use crate::raw::{OpWrite, Timestamp, oio}; +use crate::raw::OpWrite; +use crate::raw::Timestamp; +use crate::raw::oio; use crate::*; pub struct DashmapWriter { @@ -69,13 +71,10 @@ impl oio::Write for DashmapWriter { meta.set_content_encoding(v); } - self.core.set( - &self.path, - DashmapValue { - metadata: meta.clone(), - content, - }, - )?; + self.core.set(&self.path, DashmapValue { + metadata: meta.clone(), + content, + })?; Ok(meta) } diff --git a/core/src/services/dropbox/writer.rs b/core/src/services/dropbox/writer.rs index eff7c23cb..30e77808d 100644 --- a/core/src/services/dropbox/writer.rs +++ b/core/src/services/dropbox/writer.rs @@ -20,7 +20,8 @@ use std::sync::Arc; use bytes::Buf; use http::StatusCode; -use super::core::{DropboxCore, DropboxMetadataResponse}; +use super::core::DropboxCore; +use super::core::DropboxMetadataResponse; use super::error::parse_error; use crate::raw::*; use crate::*; diff --git a/core/src/services/etcd/core.rs b/core/src/services/etcd/core.rs index a2fa54b6f..6e6d9eb6e 100644 --- a/core/src/services/etcd/core.rs +++ b/core/src/services/etcd/core.rs @@ -15,16 +15,21 @@ // specific language governing permissions and limitations // under the License. -use crate::services::etcd::error::format_etcd_error; -use crate::{Buffer, Error, ErrorKind, Result}; +use std::fmt::Debug; +use std::sync::Arc; +use std::time::Duration; + use etcd_client::Client; use etcd_client::ConnectOptions; use fastpool::ManageObject; use fastpool::ObjectStatus; use fastpool::bounded; -use std::fmt::Debug; -use std::sync::Arc; -use std::time::Duration; + +use crate::Buffer; +use crate::Error; +use crate::ErrorKind; +use crate::Result; +use crate::services::etcd::error::format_etcd_error; pub mod constants { pub const DEFAULT_ETCD_ENDPOINTS: &str = "http://127.0.0.1:2379"; @@ -76,13 +81,10 @@ impl Debug for EtcdCore { impl EtcdCore { pub fn new(endpoints: Vec<String>, options: ConnectOptions) -> Self { - let client = bounded::Pool::new( - bounded::PoolConfig::new(64), - Manager { - endpoints: endpoints.clone(), - options: options.clone(), - }, - ); + let client = bounded::Pool::new(bounded::PoolConfig::new(64), Manager { + endpoints: endpoints.clone(), + options: options.clone(), + }); Self { endpoints, diff --git a/core/src/services/etcd/error.rs b/core/src/services/etcd/error.rs index 1293d9ecd..9d355df28 100644 --- a/core/src/services/etcd/error.rs +++ b/core/src/services/etcd/error.rs @@ -17,7 +17,8 @@ use etcd_client::Error as EtcdError; -use crate::{Error, ErrorKind}; +use crate::Error; +use crate::ErrorKind; pub fn format_etcd_error(e: EtcdError) -> Error { Error::new(ErrorKind::Unexpected, e.to_string().as_str()) diff --git a/core/src/services/etcd/lister.rs b/core/src/services/etcd/lister.rs index 39d143c3e..a9950a1ba 100644 --- a/core/src/services/etcd/lister.rs +++ b/core/src/services/etcd/lister.rs @@ -19,8 +19,10 @@ use std::sync::Arc; use std::vec::IntoIter; use super::core::EtcdCore; +use crate::raw::build_abs_path; +use crate::raw::build_rel_path; +use crate::raw::oio; use crate::raw::oio::Entry; -use crate::raw::{build_abs_path, build_rel_path, oio}; use crate::*; pub struct EtcdLister { diff --git a/core/src/services/ftp/backend.rs b/core/src/services/ftp/backend.rs index 555487717..8e5e7842b 100644 --- a/core/src/services/ftp/backend.rs +++ b/core/src/services/ftp/backend.rs @@ -382,13 +382,10 @@ mod build_test { #[test] fn from_uri_applies_credentials_from_query() { - let uri = OperatorUri::new( - "ftp://example.com/data", - vec![ - ("user".to_string(), "alice".to_string()), - ("password".to_string(), "secret".to_string()), - ], - ) + let uri = OperatorUri::new("ftp://example.com/data", vec![ + ("user".to_string(), "alice".to_string()), + ("password".to_string(), "secret".to_string()), + ]) .unwrap(); let cfg = FtpConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/ftp/core.rs b/core/src/services/ftp/core.rs index afe227add..be7fbef44 100644 --- a/core/src/services/ftp/core.rs +++ b/core/src/services/ftp/core.rs @@ -15,11 +15,14 @@ // specific language governing permissions and limitations // under the License. -use fastpool::{ManageObject, ObjectStatus, bounded}; -use futures_rustls::TlsConnector; -use raw::Operation; use std::sync::Arc; use std::time::Duration; + +use fastpool::ManageObject; +use fastpool::ObjectStatus; +use fastpool::bounded; +use futures_rustls::TlsConnector; +use raw::Operation; use suppaftp::AsyncRustlsConnector; use suppaftp::AsyncRustlsFtpStream; use suppaftp::FtpError; diff --git a/core/src/services/ghac/config.rs b/core/src/services/ghac/config.rs index 07469326e..1f715c4ae 100644 --- a/core/src/services/ghac/config.rs +++ b/core/src/services/ghac/config.rs @@ -111,10 +111,10 @@ mod tests { #[test] fn from_uri_respects_version_override() { - let uri = OperatorUri::new( - "ghac://cache.githubactions.io/cache-prefix", - vec![("version".to_string(), "v2".to_string())], - ) + let uri = OperatorUri::new("ghac://cache.githubactions.io/cache-prefix", vec![( + "version".to_string(), + "v2".to_string(), + )]) .unwrap(); let cfg = GhacConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/http/config.rs b/core/src/services/http/config.rs index 196bc8e75..ba929b092 100644 --- a/core/src/services/http/config.rs +++ b/core/src/services/http/config.rs @@ -114,13 +114,10 @@ mod tests { #[test] fn from_uri_ignores_endpoint_override() { - let uri = OperatorUri::new( - "http://example.com/data", - vec![( - "endpoint".to_string(), - "https://cdn.example.com".to_string(), - )], - ) + let uri = OperatorUri::new("http://example.com/data", vec![( + "endpoint".to_string(), + "https://cdn.example.com".to_string(), + )]) .unwrap(); let cfg = HttpConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/huggingface/config.rs b/core/src/services/huggingface/config.rs index 6b4034bfb..0217d7673 100644 --- a/core/src/services/huggingface/config.rs +++ b/core/src/services/huggingface/config.rs @@ -164,10 +164,10 @@ mod tests { #[test] fn from_uri_uses_existing_revision_and_sets_root() { - let uri = OperatorUri::new( - "huggingface://dataset/opendal/sample/data/train", - vec![("revision".to_string(), "dev".to_string())], - ) + let uri = OperatorUri::new("huggingface://dataset/opendal/sample/data/train", vec![( + "revision".to_string(), + "dev".to_string(), + )]) .unwrap(); let cfg = HuggingfaceConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/huggingface/core.rs b/core/src/services/huggingface/core.rs index 6aa635c59..f3b33414d 100644 --- a/core/src/services/huggingface/core.rs +++ b/core/src/services/huggingface/core.rs @@ -22,7 +22,8 @@ use bytes::Bytes; use http::Request; use http::Response; use http::header; -use percent_encoding::{NON_ALPHANUMERIC, utf8_percent_encode}; +use percent_encoding::NON_ALPHANUMERIC; +use percent_encoding::utf8_percent_encode; use serde::Deserialize; use super::backend::RepoType; @@ -248,13 +249,17 @@ pub(super) struct HuggingfaceImport { #[cfg(test)] mod tests { + use std::sync::Arc; + use std::sync::Mutex; + use bytes::Bytes; + use http::Request; + use http::Response; + use http::StatusCode; use super::*; use crate::raw::new_json_deserialize_error; use crate::types::Result; - use http::{Request, Response, StatusCode}; - use std::sync::{Arc, Mutex}; // Mock HTTP client that captures the request URL and headers #[derive(Clone)] diff --git a/core/src/services/ipmfs/builder.rs b/core/src/services/ipmfs/builder.rs index 975bcaa20..7907c1c85 100644 --- a/core/src/services/ipmfs/builder.rs +++ b/core/src/services/ipmfs/builder.rs @@ -52,8 +52,8 @@ use crate::*; /// /// ```no_run /// use anyhow::Result; -/// use opendal::services::Ipmfs; /// use opendal::Operator; +/// use opendal::services::Ipmfs; /// /// #[tokio::main] /// async fn main() -> Result<()> { diff --git a/core/src/services/lakefs/config.rs b/core/src/services/lakefs/config.rs index d6c374e3d..430eb23ac 100644 --- a/core/src/services/lakefs/config.rs +++ b/core/src/services/lakefs/config.rs @@ -167,10 +167,10 @@ mod tests { #[test] fn from_uri_respects_branch_override_and_sets_root() { - let uri = OperatorUri::new( - "lakefs://api.example.com/sample/content", - vec![("branch".to_string(), "develop".to_string())], - ) + let uri = OperatorUri::new("lakefs://api.example.com/sample/content", vec![( + "branch".to_string(), + "develop".to_string(), + )]) .unwrap(); let cfg = LakefsConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/lakefs/lister.rs b/core/src/services/lakefs/lister.rs index fe49f1529..20e4f33b0 100644 --- a/core/src/services/lakefs/lister.rs +++ b/core/src/services/lakefs/lister.rs @@ -17,12 +17,13 @@ use std::sync::Arc; +use bytes::Buf; + use super::core::LakefsCore; use super::core::LakefsListResponse; use super::error::parse_error; use crate::raw::*; use crate::*; -use bytes::Buf; pub struct LakefsLister { core: Arc<LakefsCore>, diff --git a/core/src/services/memcached/core.rs b/core/src/services/memcached/core.rs index c88d7b0be..1946fb83f 100644 --- a/core/src/services/memcached/core.rs +++ b/core/src/services/memcached/core.rs @@ -15,9 +15,12 @@ // specific language governing permissions and limitations // under the License. -use fastpool::{ManageObject, ObjectStatus, bounded}; use std::sync::Arc; use std::time::Duration; + +use fastpool::ManageObject; +use fastpool::ObjectStatus; +use fastpool::bounded; use tokio::net::TcpStream; use super::binary; diff --git a/core/src/services/mini_moka/config.rs b/core/src/services/mini_moka/config.rs index 8106858f2..9c82004df 100644 --- a/core/src/services/mini_moka/config.rs +++ b/core/src/services/mini_moka/config.rs @@ -70,10 +70,10 @@ mod tests { #[test] fn from_uri_sets_root_and_preserves_ttl() { - let uri = OperatorUri::new( - "mini-moka:///session", - vec![("time_to_live".to_string(), "300s".to_string())], - ) + let uri = OperatorUri::new("mini-moka:///session", vec![( + "time_to_live".to_string(), + "300s".to_string(), + )]) .unwrap(); let cfg = MiniMokaConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/mini_moka/writer.rs b/core/src/services/mini_moka/writer.rs index aafdacfec..0c331b12e 100644 --- a/core/src/services/mini_moka/writer.rs +++ b/core/src/services/mini_moka/writer.rs @@ -15,11 +15,13 @@ // specific language governing permissions and limitations // under the License. -use super::core::{MiniMokaCore, MiniMokaValue}; +use std::sync::Arc; + +use super::core::MiniMokaCore; +use super::core::MiniMokaValue; use crate::raw::oio; use crate::raw::*; use crate::*; -use std::sync::Arc; pub struct MiniMokaWriter { core: Arc<MiniMokaCore>, diff --git a/core/src/services/moka/backend.rs b/core/src/services/moka/backend.rs index ee28e15b9..fdc592b78 100644 --- a/core/src/services/moka/backend.rs +++ b/core/src/services/moka/backend.rs @@ -78,9 +78,11 @@ impl MokaBuilder { /// .eviction_listener(|k: Arc<String>, v: MokaValue, cause: RemovalCause| { /// debug!( /// "moka cache eviction listener, key = {}, value = {:?}, cause = {:?}", - /// k.as_str(), v.content.to_vec(), cause + /// k.as_str(), + /// v.content.to_vec(), + /// cause /// ); - /// }) + /// }), /// ); /// ``` pub fn new(builder: MokaCacheBuilder<String, MokaValue>) -> Self { diff --git a/core/src/services/moka/mod.rs b/core/src/services/moka/mod.rs index ea5bfc216..588daf085 100644 --- a/core/src/services/moka/mod.rs +++ b/core/src/services/moka/mod.rs @@ -25,7 +25,8 @@ mod deleter; mod lister; mod writer; +pub use core::MokaValue; + pub use backend::MokaBuilder as Moka; pub use backend::MokaCacheBuilder; pub use config::MokaConfig; -pub use core::MokaValue; diff --git a/core/src/services/moka/writer.rs b/core/src/services/moka/writer.rs index f1bdf09ab..1f6fc0fde 100644 --- a/core/src/services/moka/writer.rs +++ b/core/src/services/moka/writer.rs @@ -17,7 +17,8 @@ use std::sync::Arc; -use super::core::{MokaCore, MokaValue}; +use super::core::MokaCore; +use super::core::MokaValue; use crate::raw::oio; use crate::raw::*; use crate::*; diff --git a/core/src/services/obs/core.rs b/core/src/services/obs/core.rs index 33f03f549..938bf898c 100644 --- a/core/src/services/obs/core.rs +++ b/core/src/services/obs/core.rs @@ -592,10 +592,9 @@ mod tests { .collect::<Vec<String>>(), ["obj002", "obj003"], ); - assert_eq!( - out.contents.iter().map(|v| v.size).collect::<Vec<u64>>(), - [9, 10], - ); + assert_eq!(out.contents.iter().map(|v| v.size).collect::<Vec<u64>>(), [ + 9, 10 + ],); assert_eq!( out.common_prefixes .iter() diff --git a/core/src/services/opfs/core.rs b/core/src/services/opfs/core.rs index 643af84bd..ecb51c5f7 100644 --- a/core/src/services/opfs/core.rs +++ b/core/src/services/opfs/core.rs @@ -22,11 +22,10 @@ use wasm_bindgen_futures::JsFuture; use web_sys::File; use web_sys::FileSystemWritableFileStream; -use crate::Error; -use crate::Result; - use super::error::*; use super::utils::*; +use crate::Error; +use crate::Result; #[derive(Default, Debug)] pub struct OpfsCore {} diff --git a/core/src/services/opfs/error.rs b/core/src/services/opfs/error.rs index 1f7d5cb87..8507ca797 100644 --- a/core/src/services/opfs/error.rs +++ b/core/src/services/opfs/error.rs @@ -17,7 +17,8 @@ use wasm_bindgen::JsValue; -use crate::{Error, ErrorKind}; +use crate::Error; +use crate::ErrorKind; pub(crate) fn parse_js_error(msg: JsValue) -> Error { Error::new( diff --git a/core/src/services/opfs/utils.rs b/core/src/services/opfs/utils.rs index 9cc3bd25e..69c163e7a 100644 --- a/core/src/services/opfs/utils.rs +++ b/core/src/services/opfs/utils.rs @@ -15,15 +15,16 @@ // specific language governing permissions and limitations // under the License. -use crate::Result; use wasm_bindgen::JsCast; use wasm_bindgen_futures::JsFuture; -use web_sys::{ - FileSystemDirectoryHandle, FileSystemFileHandle, FileSystemGetDirectoryOptions, - FileSystemGetFileOptions, window, -}; +use web_sys::FileSystemDirectoryHandle; +use web_sys::FileSystemFileHandle; +use web_sys::FileSystemGetDirectoryOptions; +use web_sys::FileSystemGetFileOptions; +use web_sys::window; use super::error::*; +use crate::Result; pub(crate) async fn get_root_directory_handle() -> Result<FileSystemDirectoryHandle> { let navigator = window().unwrap().navigator(); diff --git a/core/src/services/oss/core.rs b/core/src/services/oss/core.rs index 78423dd76..0061e801f 100644 --- a/core/src/services/oss/core.rs +++ b/core/src/services/oss/core.rs @@ -1054,28 +1054,25 @@ mod tests { assert_eq!(out.next_continuation_token, Some("CgJiYw--".to_string())); assert!(out.common_prefixes.is_empty()); - assert_eq!( - out.contents, - vec![ - ListObjectsOutputContent { - key: "b/c".to_string(), - last_modified: "2020-05-18T05:45:54.000Z".to_string(), - etag: "\"35A27C2B9EAEEB6F48FD7FB5861D****\"".to_string(), - size: 25, - }, - ListObjectsOutputContent { - key: "ba".to_string(), - last_modified: "2020-05-18T11:17:58.000Z".to_string(), - etag: "\"35A27C2B9EAEEB6F48FD7FB5861D****\"".to_string(), - size: 25, - }, - ListObjectsOutputContent { - key: "bc".to_string(), - last_modified: "2020-05-18T05:45:59.000Z".to_string(), - etag: "\"35A27C2B9EAEEB6F48FD7FB5861D****\"".to_string(), - size: 25, - } - ] - ) + assert_eq!(out.contents, vec![ + ListObjectsOutputContent { + key: "b/c".to_string(), + last_modified: "2020-05-18T05:45:54.000Z".to_string(), + etag: "\"35A27C2B9EAEEB6F48FD7FB5861D****\"".to_string(), + size: 25, + }, + ListObjectsOutputContent { + key: "ba".to_string(), + last_modified: "2020-05-18T11:17:58.000Z".to_string(), + etag: "\"35A27C2B9EAEEB6F48FD7FB5861D****\"".to_string(), + size: 25, + }, + ListObjectsOutputContent { + key: "bc".to_string(), + last_modified: "2020-05-18T05:45:59.000Z".to_string(), + etag: "\"35A27C2B9EAEEB6F48FD7FB5861D****\"".to_string(), + size: 25, + } + ]) } } diff --git a/core/src/services/pcloud/config.rs b/core/src/services/pcloud/config.rs index d8a05c24a..f5072dba9 100644 --- a/core/src/services/pcloud/config.rs +++ b/core/src/services/pcloud/config.rs @@ -88,10 +88,10 @@ mod tests { #[test] fn from_uri_sets_endpoint_and_root() { - let uri = OperatorUri::new( - "pcloud://api.pcloud.com/drive/photos", - vec![("username".to_string(), "alice".to_string())], - ) + let uri = OperatorUri::new("pcloud://api.pcloud.com/drive/photos", vec![( + "username".to_string(), + "alice".to_string(), + )]) .unwrap(); let cfg = PcloudConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/redis/core.rs b/core/src/services/redis/core.rs index f0f5de20a..127e831ad 100644 --- a/core/src/services/redis/core.rs +++ b/core/src/services/redis/core.rs @@ -19,9 +19,10 @@ use std::fmt::Debug; use std::sync::Arc; use std::time::Duration; -use crate::*; use bytes::Bytes; -use fastpool::{ManageObject, ObjectStatus, bounded}; +use fastpool::ManageObject; +use fastpool::ObjectStatus; +use fastpool::bounded; use redis::AsyncCommands; use redis::Client; use redis::Cmd; @@ -34,6 +35,8 @@ use redis::aio::ConnectionManager; use redis::cluster::ClusterClient; use redis::cluster_async::ClusterConnection; +use crate::*; + #[derive(Clone)] pub enum RedisConnection { Normal(ConnectionManager), diff --git a/core/src/services/s3/core.rs b/core/src/services/s3/core.rs index 28576e4cd..fa2b39b95 100644 --- a/core/src/services/s3/core.rs +++ b/core/src/services/s3/core.rs @@ -1235,14 +1235,10 @@ impl ChecksumAlgorithm { } impl Display for ChecksumAlgorithm { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{}", - match self { - Self::Crc32c => "CRC32C", - Self::Md5 => "MD5", - } - ) + write!(f, "{}", match self { + Self::Crc32c => "CRC32C", + Self::Md5 => "MD5", + }) } } @@ -1497,23 +1493,20 @@ mod tests { assert!(!out.is_truncated.unwrap()); assert!(out.next_marker.is_none()); assert!(out.common_prefixes.is_empty()); - assert_eq!( - out.contents, - vec![ - ListObjectsOutputContent { - key: "my-image.jpg".to_string(), - size: 434234, - etag: Some("\"fba9dede5f27731c9771645a39863328\"".to_string()), - last_modified: "2009-10-12T17:50:30.000Z".to_string(), - }, - ListObjectsOutputContent { - key: "my-third-image.jpg".to_string(), - size: 64994, - last_modified: "2009-10-12T17:50:30.000Z".to_string(), - etag: Some("\"1b2cf535f27731c974343645a3985328\"".to_string()), - }, - ] - ) + assert_eq!(out.contents, vec![ + ListObjectsOutputContent { + key: "my-image.jpg".to_string(), + size: 434234, + etag: Some("\"fba9dede5f27731c9771645a39863328\"".to_string()), + last_modified: "2009-10-12T17:50:30.000Z".to_string(), + }, + ListObjectsOutputContent { + key: "my-third-image.jpg".to_string(), + size: 64994, + last_modified: "2009-10-12T17:50:30.000Z".to_string(), + etag: Some("\"1b2cf535f27731c974343645a3985328\"".to_string()), + }, + ]) } #[test] @@ -1567,29 +1560,26 @@ mod tests { .collect::<Vec<String>>(), vec!["photos/2006/February/", "photos/2006/January/"] ); - assert_eq!( - out.contents, - vec![ - ListObjectsOutputContent { - key: "photos/2006".to_string(), - size: 56, - etag: Some("\"d41d8cd98f00b204e9800998ecf8427e\"".to_string()), - last_modified: "2016-04-30T23:51:29.000Z".to_string(), - }, - ListObjectsOutputContent { - key: "photos/2007".to_string(), - size: 100, - last_modified: "2016-04-30T23:51:29.000Z".to_string(), - etag: Some("\"d41d8cd98f00b204e9800998ecf8427e\"".to_string()), - }, - ListObjectsOutputContent { - key: "photos/2008".to_string(), - size: 42, - last_modified: "2016-05-30T23:51:29.000Z".to_string(), - etag: None, - }, - ] - ) + assert_eq!(out.contents, vec![ + ListObjectsOutputContent { + key: "photos/2006".to_string(), + size: 56, + etag: Some("\"d41d8cd98f00b204e9800998ecf8427e\"".to_string()), + last_modified: "2016-04-30T23:51:29.000Z".to_string(), + }, + ListObjectsOutputContent { + key: "photos/2007".to_string(), + size: 100, + last_modified: "2016-04-30T23:51:29.000Z".to_string(), + etag: Some("\"d41d8cd98f00b204e9800998ecf8427e\"".to_string()), + }, + ListObjectsOutputContent { + key: "photos/2008".to_string(), + size: 42, + last_modified: "2016-05-30T23:51:29.000Z".to_string(), + etag: None, + }, + ]) } #[test] @@ -1657,48 +1647,41 @@ mod tests { output.next_version_id_marker, Some("d-d309mfjFrUmoQ0DBsVqmcMV15OI.".to_owned()) ); - assert_eq!( - output.common_prefixes, - vec![ - OutputCommonPrefix { - prefix: "photos/".to_owned() - }, - OutputCommonPrefix { - prefix: "videos/".to_owned() - } - ] - ); + assert_eq!(output.common_prefixes, vec![ + OutputCommonPrefix { + prefix: "photos/".to_owned() + }, + OutputCommonPrefix { + prefix: "videos/".to_owned() + } + ]); - assert_eq!( - output.version, - vec![ - ListObjectVersionsOutputVersion { - key: "key3".to_owned(), - version_id: "8XECiENpj8pydEDJdd-_VRrvaGKAHOaGMNW7tg6UViI.".to_owned(), - is_latest: true, - size: 217, - last_modified: "2009-12-09T00:18:23.000Z".to_owned(), - etag: Some("\"396fefef536d5ce46c7537ecf978a360\"".to_owned()), - }, - ListObjectVersionsOutputVersion { - key: "key3".to_owned(), - version_id: "d-d309mfjFri40QYukDozqBt3UmoQ0DBsVqmcMV15OI.".to_owned(), - is_latest: false, - size: 217, - last_modified: "2009-12-09T00:18:08.000Z".to_owned(), - etag: Some("\"396fefef536d5ce46c7537ecf978a360\"".to_owned()), - } - ] - ); + assert_eq!(output.version, vec![ + ListObjectVersionsOutputVersion { + key: "key3".to_owned(), + version_id: "8XECiENpj8pydEDJdd-_VRrvaGKAHOaGMNW7tg6UViI.".to_owned(), + is_latest: true, + size: 217, + last_modified: "2009-12-09T00:18:23.000Z".to_owned(), + etag: Some("\"396fefef536d5ce46c7537ecf978a360\"".to_owned()), + }, + ListObjectVersionsOutputVersion { + key: "key3".to_owned(), + version_id: "d-d309mfjFri40QYukDozqBt3UmoQ0DBsVqmcMV15OI.".to_owned(), + is_latest: false, + size: 217, + last_modified: "2009-12-09T00:18:08.000Z".to_owned(), + etag: Some("\"396fefef536d5ce46c7537ecf978a360\"".to_owned()), + } + ]); - assert_eq!( - output.delete_marker, - vec![ListObjectVersionsOutputDeleteMarker { + assert_eq!(output.delete_marker, vec![ + ListObjectVersionsOutputDeleteMarker { key: "my-third-image.jpg".to_owned(), version_id: "03jpff543dhffds434rfdsFDN943fdsFkdmqnh892".to_owned(), is_latest: true, last_modified: "2009-10-15T17:50:30.000Z".to_owned(), - },] - ); + }, + ]); } } diff --git a/core/src/services/sftp/config.rs b/core/src/services/sftp/config.rs index 999da4378..82ad894a4 100644 --- a/core/src/services/sftp/config.rs +++ b/core/src/services/sftp/config.rs @@ -96,14 +96,11 @@ mod tests { #[test] fn from_uri_applies_connection_overrides() { - let uri = OperatorUri::new( - "sftp://host", - vec![ - ("user".to_string(), "alice".to_string()), - ("key".to_string(), "/home/alice/.ssh/id_rsa".to_string()), - ("known_hosts_strategy".to_string(), "accept".to_string()), - ], - ) + let uri = OperatorUri::new("sftp://host", vec![ + ("user".to_string(), "alice".to_string()), + ("key".to_string(), "/home/alice/.ssh/id_rsa".to_string()), + ("known_hosts_strategy".to_string(), "accept".to_string()), + ]) .unwrap(); let cfg = SftpConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/sftp/core.rs b/core/src/services/sftp/core.rs index 2520a03d9..754005309 100644 --- a/core/src/services/sftp/core.rs +++ b/core/src/services/sftp/core.rs @@ -15,23 +15,27 @@ // specific language governing permissions and limitations // under the License. -use super::error::is_sftp_protocol_error; -use super::error::parse_sftp_error; -use super::error::parse_ssh_error; -use crate::raw::*; -use crate::*; -use fastpool::{ManageObject, ObjectStatus, bounded}; -use log::debug; -use openssh::KnownHosts; -use openssh::SessionBuilder; -use openssh_sftp_client::Sftp; -use openssh_sftp_client::SftpOptions; use std::fmt::Debug; use std::path::Path; use std::path::PathBuf; use std::sync::Arc; use std::time::Duration; +use fastpool::ManageObject; +use fastpool::ObjectStatus; +use fastpool::bounded; +use log::debug; +use openssh::KnownHosts; +use openssh::SessionBuilder; +use openssh_sftp_client::Sftp; +use openssh_sftp_client::SftpOptions; + +use super::error::is_sftp_protocol_error; +use super::error::parse_sftp_error; +use super::error::parse_ssh_error; +use crate::raw::*; +use crate::*; + pub struct SftpCore { pub info: Arc<AccessorInfo>, pub endpoint: String, @@ -57,16 +61,13 @@ impl SftpCore { key: Option<String>, known_hosts_strategy: KnownHosts, ) -> Self { - let client = bounded::Pool::new( - bounded::PoolConfig::new(64), - Manager { - endpoint: endpoint.clone(), - root: root.clone(), - user, - key, - known_hosts_strategy, - }, - ); + let client = bounded::Pool::new(bounded::PoolConfig::new(64), Manager { + endpoint: endpoint.clone(), + root: root.clone(), + user, + key, + known_hosts_strategy, + }); SftpCore { info, diff --git a/core/src/services/sqlite/backend.rs b/core/src/services/sqlite/backend.rs index 8b05e765b..bb453187f 100644 --- a/core/src/services/sqlite/backend.rs +++ b/core/src/services/sqlite/backend.rs @@ -313,9 +313,10 @@ impl Access for SqliteBackend { #[cfg(test)] mod test { - use super::*; use sqlx::SqlitePool; + use super::*; + async fn build_client() -> OnceCell<SqlitePool> { let config = SqliteConnectOptions::from_str("sqlite::memory:").unwrap(); let pool = SqlitePool::connect_with(config).await.unwrap(); diff --git a/core/src/services/sqlite/core.rs b/core/src/services/sqlite/core.rs index fa55643e9..a533a9db1 100644 --- a/core/src/services/sqlite/core.rs +++ b/core/src/services/sqlite/core.rs @@ -15,10 +15,11 @@ // specific language governing permissions and limitations // under the License. +use std::fmt::Debug; + use mea::once::OnceCell; use sqlx::SqlitePool; use sqlx::sqlite::SqliteConnectOptions; -use std::fmt::Debug; use crate::services::sqlite::backend::parse_sqlite_error; use crate::*; diff --git a/core/src/services/sqlite/deleter.rs b/core/src/services/sqlite/deleter.rs index 7b3ee442c..d707c58a6 100644 --- a/core/src/services/sqlite/deleter.rs +++ b/core/src/services/sqlite/deleter.rs @@ -15,7 +15,9 @@ // specific language governing permissions and limitations // under the License. -use crate::raw::{OpDelete, build_abs_path, oio}; +use crate::raw::OpDelete; +use crate::raw::build_abs_path; +use crate::raw::oio; use crate::services::sqlite::core::SqliteCore; pub struct SqliteDeleter { diff --git a/core/src/services/sqlite/writer.rs b/core/src/services/sqlite/writer.rs index bda34b255..0b45a5c6e 100644 --- a/core/src/services/sqlite/writer.rs +++ b/core/src/services/sqlite/writer.rs @@ -15,9 +15,11 @@ // specific language governing permissions and limitations // under the License. +use crate::Buffer; +use crate::EntryMode; +use crate::Metadata; use crate::raw::oio; use crate::services::sqlite::core::SqliteCore; -use crate::{Buffer, EntryMode, Metadata}; pub struct SqliteWriter { core: std::sync::Arc<SqliteCore>, diff --git a/core/src/services/swift/config.rs b/core/src/services/swift/config.rs index 14fd0c58e..764fb156e 100644 --- a/core/src/services/swift/config.rs +++ b/core/src/services/swift/config.rs @@ -115,10 +115,10 @@ mod tests { #[test] fn from_uri_accepts_container_from_query() { - let uri = OperatorUri::new( - "swift://swift.example.com", - vec![("container".to_string(), "logs".to_string())], - ) + let uri = OperatorUri::new("swift://swift.example.com", vec![( + "container".to_string(), + "logs".to_string(), + )]) .unwrap(); let cfg = SwiftConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/swift/core.rs b/core/src/services/swift/core.rs index acff08ec6..9f665e195 100644 --- a/core/src/services/swift/core.rs +++ b/core/src/services/swift/core.rs @@ -280,30 +280,21 @@ mod tests { .map_err(new_json_deserialize_error)?; assert_eq!(out.len(), 3); - assert_eq!( - out.pop().unwrap(), - ListOpResponse::FileInfo { - bytes: 147, - hash: "5e6b5b70b0426b1cc1968003e1afa5ad".to_string(), - name: "test.txt".to_string(), - last_modified: "2023-11-01T03:00:23.147480".to_string(), - content_type: Some("text/plain".to_string()), - } - ); - - assert_eq!( - out.pop().unwrap(), - ListOpResponse::Subdir { - subdir: "fruit/".to_string() - } - ); - - assert_eq!( - out.pop().unwrap(), - ListOpResponse::Subdir { - subdir: "animals/".to_string() - } - ); + assert_eq!(out.pop().unwrap(), ListOpResponse::FileInfo { + bytes: 147, + hash: "5e6b5b70b0426b1cc1968003e1afa5ad".to_string(), + name: "test.txt".to_string(), + last_modified: "2023-11-01T03:00:23.147480".to_string(), + content_type: Some("text/plain".to_string()), + }); + + assert_eq!(out.pop().unwrap(), ListOpResponse::Subdir { + subdir: "fruit/".to_string() + }); + + assert_eq!(out.pop().unwrap(), ListOpResponse::Subdir { + subdir: "animals/".to_string() + }); Ok(()) } diff --git a/core/src/services/vercel_artifacts/config.rs b/core/src/services/vercel_artifacts/config.rs index 864d9e7c1..60fc88b22 100644 --- a/core/src/services/vercel_artifacts/config.rs +++ b/core/src/services/vercel_artifacts/config.rs @@ -62,10 +62,10 @@ mod tests { #[test] fn from_uri_loads_access_token() { - let uri = OperatorUri::new( - "vercel-artifacts://cache", - vec![("access_token".to_string(), "token123".to_string())], - ) + let uri = OperatorUri::new("vercel-artifacts://cache", vec![( + "access_token".to_string(), + "token123".to_string(), + )]) .unwrap(); let cfg = VercelArtifactsConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/vercel_blob/deleter.rs b/core/src/services/vercel_blob/deleter.rs index 77f67c3b5..c71fb0a19 100644 --- a/core/src/services/vercel_blob/deleter.rs +++ b/core/src/services/vercel_blob/deleter.rs @@ -19,7 +19,8 @@ use std::sync::Arc; use super::core::VercelBlobCore; use crate::Result; -use crate::raw::{OpDelete, oio}; +use crate::raw::OpDelete; +use crate::raw::oio; pub struct VercelBlobDeleter { core: Arc<VercelBlobCore>, diff --git a/core/src/services/webdav/config.rs b/core/src/services/webdav/config.rs index de1c9c76a..d02f34858 100644 --- a/core/src/services/webdav/config.rs +++ b/core/src/services/webdav/config.rs @@ -102,13 +102,10 @@ mod tests { #[test] fn from_uri_ignores_endpoint_override() { - let uri = OperatorUri::new( - "webdav://dav.internal/data", - vec![( - "endpoint".to_string(), - "http://dav.internal:8080".to_string(), - )], - ) + let uri = OperatorUri::new("webdav://dav.internal/data", vec![( + "endpoint".to_string(), + "http://dav.internal:8080".to_string(), + )]) .unwrap(); let cfg = WebdavConfig::from_uri(&uri).unwrap(); @@ -117,10 +114,10 @@ mod tests { #[test] fn from_uri_propagates_disable_copy() { - let uri = OperatorUri::new( - "webdav://dav.example.com", - vec![("disable_copy".to_string(), "true".to_string())], - ) + let uri = OperatorUri::new("webdav://dav.example.com", vec![( + "disable_copy".to_string(), + "true".to_string(), + )]) .unwrap(); let cfg = WebdavConfig::from_uri(&uri).unwrap(); diff --git a/core/src/services/yandex_disk/config.rs b/core/src/services/yandex_disk/config.rs index b128d6272..3dc1eef10 100644 --- a/core/src/services/yandex_disk/config.rs +++ b/core/src/services/yandex_disk/config.rs @@ -75,10 +75,10 @@ mod tests { #[test] fn from_uri_sets_root_and_preserves_token() { - let uri = OperatorUri::new( - "yandex-disk://disk/root/path", - vec![("access_token".to_string(), "secret".to_string())], - ) + let uri = OperatorUri::new("yandex-disk://disk/root/path", vec![( + "access_token".to_string(), + "secret".to_string(), + )]) .unwrap(); let cfg = YandexDiskConfig::from_uri(&uri).unwrap(); diff --git a/core/src/types/buffer.rs b/core/src/types/buffer.rs index 26c4110fa..5456bc097 100644 --- a/core/src/types/buffer.rs +++ b/core/src/types/buffer.rs @@ -860,10 +860,11 @@ mod tests { .map(|chunk| chunk.to_bytes()) .collect::<Vec<Bytes>>(); - assert_eq!( - chunks, - vec![Bytes::from("abc"), Bytes::from("def"), Bytes::from("g")] - ); + assert_eq!(chunks, vec![ + Bytes::from("abc"), + Bytes::from("def"), + Bytes::from("g") + ]); assert_eq!(Buffer::new().chunks(4).count(), 0); } @@ -881,10 +882,11 @@ mod tests { .map(|chunk| chunk.to_bytes()) .collect::<Vec<Bytes>>(); - assert_eq!( - chunks, - vec![Bytes::from("ab"), Bytes::from("cd"), Bytes::from("ef"),] - ); + assert_eq!(chunks, vec![ + Bytes::from("ab"), + Bytes::from("cd"), + Bytes::from("ef"), + ]); } #[test] diff --git a/core/src/types/builder.rs b/core/src/types/builder.rs index 903459775..f9fa12908 100644 --- a/core/src/types/builder.rs +++ b/core/src/types/builder.rs @@ -37,8 +37,8 @@ use crate::*; /// /// ``` /// # use anyhow::Result; -/// use opendal::services::Fs; /// use opendal::Operator; +/// use opendal::services::Fs; /// async fn test() -> Result<()> { /// // Create fs backend builder. /// let mut builder = Fs::default().root("/tmp"); @@ -81,8 +81,8 @@ impl Builder for () { /// # use anyhow::Result; /// use std::collections::HashMap; /// -/// use opendal::services::MemoryConfig; /// use opendal::Operator; +/// use opendal::services::MemoryConfig; /// async fn test() -> Result<()> { /// let mut cfg = MemoryConfig::default(); /// cfg.root = Some("/".to_string()); @@ -101,10 +101,10 @@ impl Builder for () { /// # use anyhow::Result; /// use std::collections::HashMap; /// -/// use opendal::raw::HttpClient; -/// use opendal::services::S3Config; /// use opendal::Configurator; /// use opendal::Operator; +/// use opendal::raw::HttpClient; +/// use opendal::services::S3Config; /// /// async fn test() -> Result<()> { /// let mut cfg = S3Config::default(); diff --git a/core/src/types/delete/deleter.rs b/core/src/types/delete/deleter.rs index 4675b9751..c11ef6694 100644 --- a/core/src/types/delete/deleter.rs +++ b/core/src/types/delete/deleter.rs @@ -68,9 +68,9 @@ use crate::*; /// Deleter can be used as a Sink for file deletion: /// /// ```rust -/// use futures::stream; /// use futures::Sink; /// use futures::SinkExt; +/// use futures::stream; /// use opendal::Operator; /// use opendal::Result; /// diff --git a/core/src/types/metadata.rs b/core/src/types/metadata.rs index 901979dc4..53e642b8b 100644 --- a/core/src/types/metadata.rs +++ b/core/src/types/metadata.rs @@ -15,9 +15,10 @@ // specific language governing permissions and limitations // under the License. +use std::collections::HashMap; + use crate::raw::*; use crate::*; -use std::collections::HashMap; /// Metadata contains all the information related to a specific path. /// diff --git a/core/src/types/operator/builder.rs b/core/src/types/operator/builder.rs index 1954ea85d..c789fdc44 100644 --- a/core/src/types/operator/builder.rs +++ b/core/src/types/operator/builder.rs @@ -28,8 +28,8 @@ use crate::*; /// /// ``` /// # use anyhow::Result; -/// use opendal::services::Fs; /// use opendal::Operator; +/// use opendal::services::Fs; /// async fn test() -> Result<()> { /// // Create fs backend builder. /// let builder = Fs::default().root("/tmp"); @@ -52,8 +52,8 @@ impl Operator { /// /// ``` /// # use anyhow::Result; - /// use opendal::services::Fs; /// use opendal::Operator; + /// use opendal::services::Fs; /// async fn test() -> Result<()> { /// // Create fs backend builder. /// let builder = Fs::default().root("/tmp"); @@ -78,8 +78,8 @@ impl Operator { /// # use anyhow::Result; /// use std::collections::HashMap; /// - /// use opendal::services::MemoryConfig; /// use opendal::Operator; + /// use opendal::services::MemoryConfig; /// async fn test() -> Result<()> { /// let cfg = MemoryConfig::default(); /// @@ -107,8 +107,8 @@ impl Operator { /// # use anyhow::Result; /// use std::collections::HashMap; /// - /// use opendal::services::Fs; /// use opendal::Operator; + /// use opendal::services::Fs; /// async fn test() -> Result<()> { /// let map = HashMap::from([ /// // Set the root for fs, all operations will happen under this root. @@ -350,9 +350,9 @@ impl Operator { /// ```no_run /// # use std::sync::Arc; /// # use anyhow::Result; + /// use opendal::Operator; /// use opendal::layers::LoggingLayer; /// use opendal::services::Memory; - /// use opendal::Operator; /// /// # async fn test() -> Result<()> { /// let op = Operator::new(Memory::default())?.finish(); @@ -387,12 +387,12 @@ impl Operator { /// ``` /// use std::collections::HashMap; /// -/// use opendal::layers::LoggingLayer; -/// use opendal::layers::RetryLayer; -/// use opendal::services; /// use opendal::Builder; /// use opendal::Operator; /// use opendal::Result; +/// use opendal::layers::LoggingLayer; +/// use opendal::layers::RetryLayer; +/// use opendal::services; /// /// fn init_service<B: Builder>(cfg: HashMap<String, String>) -> Result<Operator> { /// let op = Operator::from_iter::<B>(cfg)? @@ -443,9 +443,9 @@ impl<A: Access> OperatorBuilder<A> { /// ```no_run /// # use std::sync::Arc; /// # use anyhow::Result; + /// use opendal::Operator; /// use opendal::layers::LoggingLayer; /// use opendal::services::Memory; - /// use opendal::Operator; /// /// # async fn test() -> Result<()> { /// let op = Operator::new(Memory::default())? diff --git a/core/src/types/operator/mod.rs b/core/src/types/operator/mod.rs index 3de1ea7c1..6d8faf185 100644 --- a/core/src/types/operator/mod.rs +++ b/core/src/types/operator/mod.rs @@ -30,7 +30,10 @@ pub use info::OperatorInfo; pub mod operator_futures; mod registry; -pub use registry::{DEFAULT_OPERATOR_REGISTRY, OperatorFactory, OperatorRegistry}; +pub use registry::DEFAULT_OPERATOR_REGISTRY; +pub use registry::OperatorFactory; +pub use registry::OperatorRegistry; mod uri; -pub use uri::{IntoOperatorUri, OperatorUri}; +pub use uri::IntoOperatorUri; +pub use uri::OperatorUri; diff --git a/core/src/types/operator/operator.rs b/core/src/types/operator/operator.rs index 5f255ab52..0ff8ab20f 100644 --- a/core/src/types/operator/operator.rs +++ b/core/src/types/operator/operator.rs @@ -46,8 +46,8 @@ use crate::*; /// /// ``` /// # use anyhow::Result; -/// use opendal::services::Memory; /// use opendal::Operator; +/// use opendal::services::Memory; /// async fn test() -> Result<()> { /// // Build an `Operator` to start operating the storage. /// let _: Operator = Operator::new(Memory::default())?.finish(); @@ -69,9 +69,9 @@ use crate::*; /// /// ``` /// # use anyhow::Result; +/// use opendal::Operator; /// use opendal::layers::RetryLayer; /// use opendal::services::Memory; -/// use opendal::Operator; /// async fn test() -> Result<()> { /// let op: Operator = Operator::new(Memory::default())?.finish(); /// @@ -102,11 +102,11 @@ use crate::*; /// into [`futures::AsyncRead`] or [`futures::Stream`] for broader ecosystem compatibility. /// /// ```no_run +/// use opendal::Operator; +/// use opendal::Result; /// use opendal::layers::LoggingLayer; /// use opendal::options; /// use opendal::services; -/// use opendal::Operator; -/// use opendal::Result; /// /// #[tokio::main] /// async fn main() -> Result<()> { @@ -372,8 +372,8 @@ impl Operator { /// # use anyhow::Result; /// # use futures::io; /// # use opendal::Operator; - /// use opendal::options; /// use opendal::ErrorKind; + /// use opendal::options; /// # /// # async fn test(op: Operator) -> Result<()> { /// let res = op @@ -1134,7 +1134,8 @@ impl Operator { /// # async fn test(op: Operator) -> Result<()> { /// let mut opts = CopyOptions::default(); /// opts.if_not_exists = true; - /// op.copy_options("path/to/file", "path/to/file2", opts).await?; + /// op.copy_options("path/to/file", "path/to/file2", opts) + /// .await?; /// # Ok(()) /// # } /// ``` @@ -1577,9 +1578,9 @@ impl Operator { /// /// ``` /// # use anyhow::Result; - /// use opendal::options; /// use opendal::EntryMode; /// use opendal::Operator; + /// use opendal::options; /// # async fn test(op: Operator) -> Result<()> { /// let mut entries = op /// .list_options("path/to/prefix", options::ListOptions { @@ -1705,9 +1706,9 @@ impl Operator { /// ``` /// # use anyhow::Result; /// use futures::TryStreamExt; - /// use opendal::options; /// use opendal::EntryMode; /// use opendal::Operator; + /// use opendal::options; /// # async fn test(op: Operator) -> Result<()> { /// let mut lister = op /// .lister_options("path/to/dir/", options::ListOptions { diff --git a/core/src/types/operator/operator_futures.rs b/core/src/types/operator/operator_futures.rs index 1a1276bb1..66a0d0f33 100644 --- a/core/src/types/operator/operator_futures.rs +++ b/core/src/types/operator/operator_futures.rs @@ -24,9 +24,10 @@ use std::future::IntoFuture; use std::ops::RangeBounds; use std::time::Duration; +use futures::Future; + use crate::raw::*; use crate::*; -use futures::Future; /// OperatorFuture is the future generated by [`Operator`]. /// diff --git a/core/src/types/operator/registry.rs b/core/src/types/operator/registry.rs index 4aedc77d7..fb788c47f 100644 --- a/core/src/types/operator/registry.rs +++ b/core/src/types/operator/registry.rs @@ -16,11 +16,17 @@ // under the License. use std::collections::HashMap; -use std::sync::{LazyLock, Mutex}; +use std::sync::LazyLock; +use std::sync::Mutex; -use crate::types::builder::{Builder, Configurator}; -use crate::types::{IntoOperatorUri, OperatorUri}; -use crate::{Error, ErrorKind, Operator, Result}; +use crate::Error; +use crate::ErrorKind; +use crate::Operator; +use crate::Result; +use crate::types::IntoOperatorUri; +use crate::types::OperatorUri; +use crate::types::builder::Builder; +use crate::types::builder::Configurator; /// Factory signature used to construct [`Operator`] from a URI and extra options. pub type OperatorFactory = fn(&OperatorUri) -> Result<Operator>; diff --git a/core/src/types/operator/uri.rs b/core/src/types/operator/uri.rs index 4a4e3bed3..0eca5b06c 100644 --- a/core/src/types/operator/uri.rs +++ b/core/src/types/operator/uri.rs @@ -21,7 +21,9 @@ use http::Uri; use percent_encoding::percent_decode_str; use url::Url; -use crate::{Error, ErrorKind, Result}; +use crate::Error; +use crate::ErrorKind; +use crate::Result; /// Parsed representation of an operator URI with normalized components. #[derive(Clone, Debug, Eq, PartialEq)] @@ -268,10 +270,10 @@ mod tests { #[test] fn into_operator_uri_merges_extra_options() { - let uri = ( - "s3://bucket/path?region=us-east-1", - vec![("region", "override"), ("endpoint", "https://custom")], - ) + let uri = ("s3://bucket/path?region=us-east-1", vec![ + ("region", "override"), + ("endpoint", "https://custom"), + ]) .into_operator_uri() .unwrap(); diff --git a/core/src/types/options.rs b/core/src/types/options.rs index d6d81a5a8..ee5064eec 100644 --- a/core/src/types/options.rs +++ b/core/src/types/options.rs @@ -17,9 +17,11 @@ //! Options module provides options definitions for operations. -use crate::raw::{BytesRange, Timestamp}; use std::collections::HashMap; +use crate::raw::BytesRange; +use crate::raw::Timestamp; + /// Options for delete operations. #[derive(Debug, Clone, Default, Eq, PartialEq)] pub struct DeleteOptions { diff --git a/rustfmt.toml b/rustfmt.toml index 383062d6b..d39acfe67 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -23,4 +23,3 @@ reorder_imports = true # imports_granularity = "Item" # overflow_delimited_expr = true # trailing_comma = "Vertical" -# where_single_line = true
