diff --git a/bin/oay/src/services/webdav/service.rs b/bin/oay/src/services/webdav/service.rs index 71bc31499e14..9b5673eb9e81 100644 --- a/bin/oay/src/services/webdav/service.rs +++ b/bin/oay/src/services/webdav/service.rs @@ -23,10 +23,10 @@ use axum::http::Request; use axum::routing::any_service; use axum::Router; use dav_server::DavHandler; +use dav_server_opendalfs::OpendalFs; use opendal::Operator; use crate::Config; -use dav_server_opendalfs::OpendalFs; pub struct WebdavService { cfg: Arc, diff --git a/bindings/c/src/entry.rs b/bindings/c/src/entry.rs index 44e9c2f19ad6..f71b65337741 100644 --- a/bindings/c/src/entry.rs +++ b/bindings/c/src/entry.rs @@ -15,10 +15,11 @@ // specific language governing permissions and limitations // under the License. -use ::opendal as core; use std::ffi::CString; use std::os::raw::c_char; +use ::opendal as core; + /// \brief opendal_list_entry is the entry under a path, which is listed from the opendal_lister /// /// For examples, please see the comment section of opendal_operator_list() diff --git a/bindings/c/src/operator_info.rs b/bindings/c/src/operator_info.rs index 9785700fd782..4d805e4de06a 100644 --- a/bindings/c/src/operator_info.rs +++ b/bindings/c/src/operator_info.rs @@ -15,7 +15,8 @@ // specific language governing permissions and limitations // under the License. -use std::ffi::{c_char, CString}; +use std::ffi::c_char; +use std::ffi::CString; use ::opendal as core; diff --git a/bindings/c/src/reader.rs b/bindings/c/src/reader.rs index f9c52fc17f73..d0604aeebb8e 100644 --- a/bindings/c/src/reader.rs +++ b/bindings/c/src/reader.rs @@ -15,10 +15,12 @@ // specific language governing permissions and limitations // under the License. -use super::*; -use ::opendal as core; use std::io::Read; +use ::opendal as core; + +use super::*; + /// \brief The result type returned by opendal's reader operation. /// /// \note The opendal_reader actually owns a pointer to diff --git a/bindings/java/Cargo.toml b/bindings/java/Cargo.toml index 2fcff3da75b8..c1b62f30b8f3 100644 --- a/bindings/java/Cargo.toml +++ b/bindings/java/Cargo.toml @@ -105,6 +105,7 @@ services-webdav = ["opendal/services-webdav"] services-webhdfs = ["opendal/services-webhdfs"] # Optional services provided by opendal. +services-alluxio = ["opendal/services-alluxio"] services-azfile = ["opendal/services-azfile"] services-cacache = ["opendal/services-cacache"] services-dashmap = ["opendal/services-dashmap"] @@ -136,7 +137,6 @@ services-swift = ["opendal/services-swift"] services-tikv = ["opendal/services-tikv"] services-vercel-artifacts = ["opendal/services-vercel-artifacts"] services-wasabi = ["opendal/services-wasabi"] -services-alluxio = ["opendal/services-alluxio"] [dependencies] anyhow = "1.0.71" diff --git a/bindings/java/src/blocking_operator.rs b/bindings/java/src/blocking_operator.rs index a87cd9b44579..f2d77302c0c9 100644 --- a/bindings/java/src/blocking_operator.rs +++ b/bindings/java/src/blocking_operator.rs @@ -19,12 +19,12 @@ use jni::objects::JByteArray; use jni::objects::JClass; use jni::objects::JObject; use jni::objects::JString; +use jni::sys::jbyteArray; +use jni::sys::jlong; use jni::sys::jobject; use jni::sys::jobjectArray; use jni::sys::jsize; -use jni::sys::{jbyteArray, jlong}; use jni::JNIEnv; - use opendal::BlockingOperator; use crate::convert::jstring_to_string; diff --git a/bindings/java/src/convert.rs b/bindings/java/src/convert.rs index 115bc9981aeb..e347fffc8262 100644 --- a/bindings/java/src/convert.rs +++ b/bindings/java/src/convert.rs @@ -15,10 +15,13 @@ // specific language governing permissions and limitations // under the License. -use jni::objects::{JMap, JObject, JString}; +use std::collections::HashMap; + +use jni::objects::JMap; +use jni::objects::JObject; +use jni::objects::JString; use jni::sys::jlong; use jni::JNIEnv; -use std::collections::HashMap; pub(crate) fn usize_to_jlong(n: Option) -> jlong { // usize is always >= 0, so we can use -1 to identify the empty value. diff --git a/bindings/java/src/layer.rs b/bindings/java/src/layer.rs index 3706d77f53d5..7e3ba35fd172 100644 --- a/bindings/java/src/layer.rs +++ b/bindings/java/src/layer.rs @@ -18,9 +18,10 @@ use std::time::Duration; use jni::objects::JClass; -use jni::sys::{jboolean, jfloat, jlong}; +use jni::sys::jboolean; +use jni::sys::jfloat; +use jni::sys::jlong; use jni::JNIEnv; - use opendal::layers::RetryLayer; use opendal::Operator; diff --git a/bindings/java/src/operator.rs b/bindings/java/src/operator.rs index e4a13430b780..5d05f2102690 100644 --- a/bindings/java/src/operator.rs +++ b/bindings/java/src/operator.rs @@ -24,10 +24,10 @@ use jni::objects::JObject; use jni::objects::JString; use jni::objects::JValue; use jni::objects::JValueOwned; +use jni::sys::jlong; +use jni::sys::jobject; use jni::sys::jsize; -use jni::sys::{jlong, jobject}; use jni::JNIEnv; - use opendal::layers::BlockingLayer; use opendal::raw::PresignedRequest; use opendal::Operator; diff --git a/bindings/java/src/utility.rs b/bindings/java/src/utility.rs index b3190db7beb7..02f382ec80e2 100644 --- a/bindings/java/src/utility.rs +++ b/bindings/java/src/utility.rs @@ -15,10 +15,11 @@ // specific language governing permissions and limitations // under the License. -use jni::objects::{JClass, JObject}; -use jni::sys::{jobjectArray, jsize}; +use jni::objects::JClass; +use jni::objects::JObject; +use jni::sys::jobjectArray; +use jni::sys::jsize; use jni::JNIEnv; - use opendal::Scheme; use crate::convert::string_to_jstring; diff --git a/bindings/nodejs/Cargo.toml b/bindings/nodejs/Cargo.toml index 92d7c451c02c..9ad4eff0a361 100644 --- a/bindings/nodejs/Cargo.toml +++ b/bindings/nodejs/Cargo.toml @@ -101,6 +101,7 @@ services-webdav = ["opendal/services-webdav"] services-webhdfs = ["opendal/services-webhdfs"] # Optional services provided by opendal. +services-alluxio = ["opendal/services-alluxio"] services-azfile = ["opendal/services-azfile"] services-cacache = ["opendal/services-cacache"] services-dashmap = ["opendal/services-dashmap"] @@ -132,7 +133,6 @@ services-swift = ["opendal/services-swift"] services-tikv = ["opendal/services-tikv"] services-vercel-artifacts = ["opendal/services-vercel-artifacts"] services-wasabi = ["opendal/services-wasabi"] -services-alluxio = ["opendal/services-alluxio"] [lib] crate-type = ["cdylib"] diff --git a/bindings/nodejs/index.d.ts b/bindings/nodejs/index.d.ts index 0d0455b0b632..6c6ceba31a9e 100644 --- a/bindings/nodejs/index.d.ts +++ b/bindings/nodejs/index.d.ts @@ -468,7 +468,7 @@ export class Layer { } * retry.jitter = true; * * op.layer(retry.build()); - *``` + * ``` */ export class RetryLayer { constructor() diff --git a/bindings/nodejs/src/lib.rs b/bindings/nodejs/src/lib.rs index e994e1facb07..3cb8b86703c4 100644 --- a/bindings/nodejs/src/lib.rs +++ b/bindings/nodejs/src/lib.rs @@ -731,7 +731,7 @@ impl NodeLayer for opendal::layers::RetryLayer { /// retry.jitter = true; /// /// op.layer(retry.build()); -///``` +/// ``` #[derive(Default)] #[napi] pub struct RetryLayer { diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml index 553575f7117d..8a51cbda4b09 100644 --- a/bindings/python/Cargo.toml +++ b/bindings/python/Cargo.toml @@ -101,6 +101,7 @@ services-webdav = ["opendal/services-webdav"] services-webhdfs = ["opendal/services-webhdfs"] # Optional services provided by opendal. +services-alluxio = ["opendal/services-alluxio"] services-azfile = ["opendal/services-azfile"] services-cacache = ["opendal/services-cacache"] services-dashmap = ["opendal/services-dashmap"] @@ -132,7 +133,6 @@ services-swift = ["opendal/services-swift"] services-tikv = ["opendal/services-tikv"] services-vercel-artifacts = ["opendal/services-vercel-artifacts"] services-wasabi = ["opendal/services-wasabi"] -services-alluxio = ["opendal/services-alluxio"] [lib] crate-type = ["cdylib"] diff --git a/bindings/python/src/file.rs b/bindings/python/src/file.rs index 8db6452b3a23..09cc6daeb852 100644 --- a/bindings/python/src/file.rs +++ b/bindings/python/src/file.rs @@ -15,14 +15,16 @@ // specific language governing permissions and limitations // under the License. +use std::io::Read; use std::io::Seek; use std::io::SeekFrom; -use std::io::{Read, Write}; +use std::io::Write; use std::ops::DerefMut; use std::sync::Arc; +use futures::AsyncReadExt; use futures::AsyncSeekExt; -use futures::{AsyncReadExt, AsyncWriteExt}; +use futures::AsyncWriteExt; use pyo3::exceptions::PyIOError; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; diff --git a/bindings/python/src/lister.rs b/bindings/python/src/lister.rs index d2e7fe89c3ed..e108ec2dcc36 100644 --- a/bindings/python/src/lister.rs +++ b/bindings/python/src/lister.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -use futures::TryStreamExt; use std::sync::Arc; +use futures::TryStreamExt; use pyo3::exceptions::PyStopAsyncIteration; use pyo3::prelude::*; use pyo3_asyncio::tokio::future_into_py; diff --git a/bindings/python/src/operator.rs b/bindings/python/src/operator.rs index d8e6763afd3a..c8057deacb46 100644 --- a/bindings/python/src/operator.rs +++ b/bindings/python/src/operator.rs @@ -21,7 +21,8 @@ use std::time::Duration; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; -use pyo3::types::{PyBytes, PyDict}; +use pyo3::types::PyBytes; +use pyo3::types::PyDict; use pyo3_asyncio::tokio::future_into_py; use crate::*; diff --git a/core/Cargo.toml b/core/Cargo.toml index 9b74ff691cb3..7a77484e23c0 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -111,6 +111,7 @@ layers-await-tree = ["dep:await-tree"] # Enable layers async-backtrace support. layers-async-backtrace = ["dep:async-backtrace"] +services-alluxio = [] services-atomicserver = ["dep:atomic_lib"] services-azblob = [ "dep:sha2", @@ -148,7 +149,6 @@ services-gdrive = [] services-ghac = [] services-gridfs = ["dep:mongodb"] services-hdfs = ["dep:hdrs"] -services-alluxio = [] services-http = [] services-ipfs = ["dep:prost"] services-ipmfs = [] diff --git a/core/edge/file_write_on_full_disk/src/main.rs b/core/edge/file_write_on_full_disk/src/main.rs index 63cfe6cf050b..f232ac5ff801 100644 --- a/core/edge/file_write_on_full_disk/src/main.rs +++ b/core/edge/file_write_on_full_disk/src/main.rs @@ -15,11 +15,12 @@ // specific language governing permissions and limitations // under the License. +use std::env; + use opendal::services::Fs; use opendal::Operator; use opendal::Result; use rand::prelude::*; -use std::env; #[tokio::main] async fn main() -> Result<()> { diff --git a/core/fuzz/fuzz_reader.rs b/core/fuzz/fuzz_reader.rs index bda286a18247..b0f83fc03b60 100644 --- a/core/fuzz/fuzz_reader.rs +++ b/core/fuzz/fuzz_reader.rs @@ -17,7 +17,8 @@ #![no_main] -use std::fmt::{Debug, Formatter}; +use std::fmt::Debug; +use std::fmt::Formatter; use std::io::SeekFrom; use libfuzzer_sys::arbitrary::Arbitrary; diff --git a/core/src/layers/immutable_index.rs b/core/src/layers/immutable_index.rs index 764f5ecc8df7..4a57f4e1993f 100644 --- a/core/src/layers/immutable_index.rs +++ b/core/src/layers/immutable_index.rs @@ -17,7 +17,8 @@ use std::collections::HashSet; use std::fmt::Debug; -use std::task::{Context, Poll}; +use std::task::Context; +use std::task::Poll; use std::vec::IntoIter; use async_trait::async_trait; diff --git a/core/src/layers/prometheus_client.rs b/core/src/layers/prometheus_client.rs index fa9e7ec3d1fb..a43d24f0afb2 100644 --- a/core/src/layers/prometheus_client.rs +++ b/core/src/layers/prometheus_client.rs @@ -21,7 +21,8 @@ use std::io; use std::sync::Arc; use std::task::Context; use std::task::Poll; -use std::time::{Duration, Instant}; +use std::time::Duration; +use std::time::Instant; use async_trait::async_trait; use bytes::Bytes; diff --git a/core/src/raw/layer.rs b/core/src/raw/layer.rs index 48619c9be79e..da21eca64ec2 100644 --- a/core/src/raw/layer.rs +++ b/core/src/raw/layer.rs @@ -96,7 +96,11 @@ use crate::*; /// self.inner.list(path, args).await /// } /// -/// fn blocking_list(&self, path: &str, args: OpList) -> Result<(RpList, Self::BlockingLister)> { +/// fn blocking_list( +/// &self, +/// path: &str, +/// args: OpList, +/// ) -> Result<(RpList, Self::BlockingLister)> { /// self.inner.blocking_list(path, args) /// } /// } diff --git a/core/src/raw/oio/buf/adaptive.rs b/core/src/raw/oio/buf/adaptive.rs index abebcb36f6c3..3ebf361b5694 100644 --- a/core/src/raw/oio/buf/adaptive.rs +++ b/core/src/raw/oio/buf/adaptive.rs @@ -15,8 +15,10 @@ // specific language governing permissions and limitations // under the License. -use bytes::{Bytes, BytesMut}; use std::cmp; + +use bytes::Bytes; +use bytes::BytesMut; use tokio::io::ReadBuf; /// The default minimum adaptive buffer size is 8 KiB. diff --git a/core/src/raw/oio/list/api.rs b/core/src/raw/oio/list/api.rs index cb6ed0fa058f..920b48c56587 100644 --- a/core/src/raw/oio/list/api.rs +++ b/core/src/raw/oio/list/api.rs @@ -17,9 +17,8 @@ use std::fmt::Display; use std::fmt::Formatter; -use std::task::{Context, Poll}; - -use async_trait::async_trait; +use std::task::Context; +use std::task::Poll; use crate::raw::oio::Entry; use crate::*; @@ -59,7 +58,6 @@ impl From for &'static str { } /// Page trait is used by [`raw::Accessor`] to implement `list` operation. -#[async_trait] pub trait List: Send + Sync + 'static { /// Fetch a new page of [`Entry`] /// @@ -71,21 +69,18 @@ pub trait List: Send + Sync + 'static { /// The boxed version of [`List`] pub type Lister = Box; -#[async_trait] impl List for Box

{ fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { (**self).poll_next(cx) } } -#[async_trait] impl List for () { fn poll_next(&mut self, _: &mut Context<'_>) -> Poll>> { Poll::Ready(Ok(None)) } } -#[async_trait] impl List for Option

{ fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { match self { diff --git a/core/src/raw/oio/list/flat_list.rs b/core/src/raw/oio/list/flat_list.rs index 2d40b13fd04a..3328c74b8ec0 100644 --- a/core/src/raw/oio/list/flat_list.rs +++ b/core/src/raw/oio/list/flat_list.rs @@ -15,9 +15,10 @@ // specific language governing permissions and limitations // under the License. -use std::task::{ready, Context, Poll}; +use std::task::ready; +use std::task::Context; +use std::task::Poll; -use async_trait::async_trait; use futures::future::BoxFuture; use futures::FutureExt; @@ -102,7 +103,6 @@ where } } -#[async_trait] impl oio::List for FlatLister where A: Accessor, @@ -208,6 +208,7 @@ where #[cfg(test)] mod tests { + use async_trait::async_trait; use std::collections::HashMap; use std::vec; use std::vec::IntoIter; diff --git a/core/src/raw/oio/list/hierarchy_list.rs b/core/src/raw/oio/list/hierarchy_list.rs index 79d26b3ac456..3c67abc1154e 100644 --- a/core/src/raw/oio/list/hierarchy_list.rs +++ b/core/src/raw/oio/list/hierarchy_list.rs @@ -16,14 +16,14 @@ // under the License. use std::collections::HashSet; -use std::task::{ready, Context, Poll}; - -use async_trait::async_trait; +use std::task::ready; +use std::task::Context; +use std::task::Poll; use crate::raw::*; use crate::*; -/// ToHierarchyLister will convert a flat page to hierarchy by filter +/// ToHierarchyLister will convert a flat list to hierarchy by filter /// not needed entries. /// /// # Notes @@ -32,7 +32,7 @@ use crate::*; /// to return an empty vec. It doesn't mean the all pages have been /// returned. /// -/// Please keep calling next_page until we returned `Ok(None)` +/// Please keep calling next until we returned `Ok(None)` pub struct HierarchyLister

{ lister: P, path: String, @@ -117,7 +117,6 @@ impl

HierarchyLister

{ } } -#[async_trait] impl oio::List for HierarchyLister

{ fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { loop { diff --git a/core/src/raw/oio/list/page_list.rs b/core/src/raw/oio/list/page_list.rs index 196f228b06c2..eb98a98bd3b2 100644 --- a/core/src/raw/oio/list/page_list.rs +++ b/core/src/raw/oio/list/page_list.rs @@ -15,10 +15,13 @@ // specific language governing permissions and limitations // under the License. +use std::collections::VecDeque; +use std::task::ready; +use std::task::Context; +use std::task::Poll; + use async_trait::async_trait; use futures::future::BoxFuture; -use std::collections::VecDeque; -use std::task::{ready, Context, Poll}; use crate::raw::*; use crate::*; diff --git a/core/src/raw/oio/read/api.rs b/core/src/raw/oio/read/api.rs index 09859985515a..2c25f998104f 100644 --- a/core/src/raw/oio/read/api.rs +++ b/core/src/raw/oio/read/api.rs @@ -15,12 +15,14 @@ // specific language governing permissions and limitations // under the License. +use std::cmp; use std::fmt::Display; use std::fmt::Formatter; +use std::io; use std::pin::Pin; +use std::task::ready; +use std::task::Context; use std::task::Poll; -use std::task::{ready, Context}; -use std::{cmp, io}; use bytes::Bytes; use futures::Future; diff --git a/core/src/raw/oio/read/file_read.rs b/core/src/raw/oio/read/file_read.rs index 2c403f4a688d..fd8a537753de 100644 --- a/core/src/raw/oio/read/file_read.rs +++ b/core/src/raw/oio/read/file_read.rs @@ -16,7 +16,6 @@ // under the License. use std::cmp; - use std::io::SeekFrom; use std::pin::Pin; use std::sync::Arc; diff --git a/core/src/raw/oio/read/futures_read.rs b/core/src/raw/oio/read/futures_read.rs index 03b52bbf74ee..8b3bd3999d9d 100644 --- a/core/src/raw/oio/read/futures_read.rs +++ b/core/src/raw/oio/read/futures_read.rs @@ -15,14 +15,17 @@ // specific language governing permissions and limitations // under the License. -use crate::raw::*; -use crate::*; +use std::io::SeekFrom; +use std::pin::Pin; +use std::task::Context; +use std::task::Poll; + use bytes::Bytes; use futures::AsyncRead; use futures::AsyncSeek; -use std::io::SeekFrom; -use std::pin::Pin; -use std::task::{Context, Poll}; + +use crate::raw::*; +use crate::*; /// FuturesReader implements [`oio::Read`] via [`AsyncRead`] + [`AsyncSeek`]. pub struct FuturesReader { diff --git a/core/src/raw/oio/read/lazy_read.rs b/core/src/raw/oio/read/lazy_read.rs index 89705deff534..f6237f6569de 100644 --- a/core/src/raw/oio/read/lazy_read.rs +++ b/core/src/raw/oio/read/lazy_read.rs @@ -15,15 +15,19 @@ // specific language governing permissions and limitations // under the License. -use crate::raw::*; -use crate::*; -use bytes::Bytes; -use futures::future::BoxFuture; -use futures::Future; use std::io::SeekFrom; use std::pin::Pin; use std::sync::Arc; -use std::task::{ready, Context, Poll}; +use std::task::ready; +use std::task::Context; +use std::task::Poll; + +use bytes::Bytes; +use futures::future::BoxFuture; +use futures::Future; + +use crate::raw::*; +use crate::*; /// LazyReader implements [`oio::Read`] in a lazy way. /// diff --git a/core/src/raw/oio/read/std_read.rs b/core/src/raw/oio/read/std_read.rs index 926b9abb358c..d28f8d5ca342 100644 --- a/core/src/raw/oio/read/std_read.rs +++ b/core/src/raw/oio/read/std_read.rs @@ -15,11 +15,14 @@ // specific language governing permissions and limitations // under the License. +use std::io::Read; +use std::io::Seek; +use std::io::SeekFrom; + +use bytes::Bytes; + use crate::raw::*; use crate::*; -use bytes::Bytes; -use std::io::Seek; -use std::io::{Read, SeekFrom}; /// FuturesReader implements [`oio::BlockingRead`] via [`Read`] + [`Seek`]. pub struct StdReader { diff --git a/core/src/raw/oio/read/tokio_read.rs b/core/src/raw/oio/read/tokio_read.rs index 966973bdc3c8..37aabc14732b 100644 --- a/core/src/raw/oio/read/tokio_read.rs +++ b/core/src/raw/oio/read/tokio_read.rs @@ -15,14 +15,19 @@ // specific language governing permissions and limitations // under the License. -use crate::raw::*; -use crate::*; -use bytes::Bytes; use std::io::SeekFrom; use std::pin::Pin; -use std::task::{ready, Context, Poll}; +use std::task::ready; +use std::task::Context; +use std::task::Poll; + +use bytes::Bytes; +use tokio::io::AsyncRead; use tokio::io::AsyncSeek; -use tokio::io::{AsyncRead, ReadBuf}; +use tokio::io::ReadBuf; + +use crate::raw::*; +use crate::*; /// FuturesReader implements [`oio::Read`] via [`AsyncRead`] + [`AsyncSeek`]. pub struct TokioReader { diff --git a/core/src/raw/oio/write/api.rs b/core/src/raw/oio/write/api.rs index cebaffc70961..13612565744e 100644 --- a/core/src/raw/oio/write/api.rs +++ b/core/src/raw/oio/write/api.rs @@ -22,7 +22,6 @@ use std::pin::Pin; use std::task::Context; use std::task::Poll; -use async_trait::async_trait; use pin_project::pin_project; use crate::raw::*; @@ -75,7 +74,6 @@ impl From for &'static str { pub type Writer = Box; /// Write is the trait that OpenDAL returns to callers. -#[async_trait] pub trait Write: Unpin + Send + Sync { /// Write given bytes into writer. /// @@ -95,7 +93,6 @@ pub trait Write: Unpin + Send + Sync { fn poll_abort(&mut self, cx: &mut Context<'_>) -> Poll>; } -#[async_trait] impl Write for () { fn poll_write(&mut self, _: &mut Context<'_>, _: &dyn oio::WriteBuf) -> Poll> { unimplemented!("write is required to be implemented for oio::Write") @@ -119,7 +116,6 @@ impl Write for () { /// `Box` won't implement `Write` automatically. /// /// To make Writer work as expected, we must add this impl. -#[async_trait] impl Write for Box { fn poll_write(&mut self, cx: &mut Context<'_>, bs: &dyn oio::WriteBuf) -> Poll> { (**self).poll_write(cx, bs) diff --git a/core/src/raw/oio/write/append_object_write.rs b/core/src/raw/oio/write/append_object_write.rs index d5c030f74df5..93d182f40dfb 100644 --- a/core/src/raw/oio/write/append_object_write.rs +++ b/core/src/raw/oio/write/append_object_write.rs @@ -77,7 +77,6 @@ impl AppendObjectWriter { } } -#[async_trait] impl oio::Write for AppendObjectWriter where W: AppendObjectWrite, diff --git a/core/src/raw/oio/write/exact_buf_write.rs b/core/src/raw/oio/write/exact_buf_write.rs index 02ab9d926578..122e342c1714 100644 --- a/core/src/raw/oio/write/exact_buf_write.rs +++ b/core/src/raw/oio/write/exact_buf_write.rs @@ -102,7 +102,6 @@ mod tests { buf: Vec, } - #[async_trait] impl Write for MockWriter { fn poll_write(&mut self, _: &mut Context<'_>, bs: &dyn WriteBuf) -> Poll> { debug!( diff --git a/core/src/raw/oio/write/one_shot_write.rs b/core/src/raw/oio/write/one_shot_write.rs index 4efb3655b0d6..a015b98a1672 100644 --- a/core/src/raw/oio/write/one_shot_write.rs +++ b/core/src/raw/oio/write/one_shot_write.rs @@ -68,25 +68,21 @@ impl OneShotWriter { #[async_trait] impl oio::Write for OneShotWriter { fn poll_write(&mut self, _: &mut Context<'_>, bs: &dyn oio::WriteBuf) -> Poll> { - loop { - match &mut self.state { - State::Idle(_) => { - return match &self.buffer { - Some(_) => Poll::Ready(Err(Error::new( - ErrorKind::Unsupported, - "OneShotWriter doesn't support multiple write", - ))), - None => { - let size = bs.remaining(); - let bs = bs.vectored_bytes(size); - self.buffer = Some(oio::ChunkedBytes::from_vec(bs)); - Poll::Ready(Ok(size)) - } - } - } - State::Write(_) => { - unreachable!("OneShotWriter must not go into State::Write during poll_write") + match &mut self.state { + State::Idle(_) => match &self.buffer { + Some(_) => Poll::Ready(Err(Error::new( + ErrorKind::Unsupported, + "OneShotWriter doesn't support multiple write", + ))), + None => { + let size = bs.remaining(); + let bs = bs.vectored_bytes(size); + self.buffer = Some(oio::ChunkedBytes::from_vec(bs)); + Poll::Ready(Ok(size)) } + }, + State::Write(_) => { + unreachable!("OneShotWriter must not go into State::Write during poll_write") } } } diff --git a/core/src/raw/serde_util.rs b/core/src/raw/serde_util.rs index 5edde1dde5af..09ab11cb452f 100644 --- a/core/src/raw/serde_util.rs +++ b/core/src/raw/serde_util.rs @@ -15,12 +15,17 @@ // specific language governing permissions and limitations // under the License. -use serde::de::value::{MapDeserializer, SeqDeserializer}; -use serde::de::{self, Deserializer, IntoDeserializer, Visitor}; use std::collections::hash_map::IntoIter; use std::collections::HashMap; use std::iter::empty; +use serde::de::value::MapDeserializer; +use serde::de::value::SeqDeserializer; +use serde::de::Deserializer; +use serde::de::IntoDeserializer; +use serde::de::Visitor; +use serde::de::{self}; + use crate::*; /// Parse xml deserialize error into opendal::Error. @@ -303,9 +308,10 @@ impl<'de> Deserializer<'de> for Pair { #[cfg(test)] mod tests { - use super::*; use serde::Deserialize; + use super::*; + #[derive(Debug, Default, Deserialize, Eq, PartialEq)] #[serde(default)] #[non_exhaustive] diff --git a/core/src/raw/tests/read.rs b/core/src/raw/tests/read.rs index 526af48e5ff6..6c6a3b3d22fa 100644 --- a/core/src/raw/tests/read.rs +++ b/core/src/raw/tests/read.rs @@ -15,12 +15,16 @@ // specific language governing permissions and limitations // under the License. +use std::io::SeekFrom; + +use bytes::Bytes; +use rand::thread_rng; +use rand::RngCore; +use sha2::Digest; +use sha2::Sha256; + use crate::raw::*; use crate::*; -use bytes::Bytes; -use rand::{thread_rng, RngCore}; -use sha2::{Digest, Sha256}; -use std::io::SeekFrom; /// ReadAction represents a read action. #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/core/src/raw/tests/utils.rs b/core/src/raw/tests/utils.rs index 2ecda5b79c02..9456b966c1da 100644 --- a/core/src/raw/tests/utils.rs +++ b/core/src/raw/tests/utils.rs @@ -15,12 +15,14 @@ // specific language governing permissions and limitations // under the License. -use crate::*; -use once_cell::sync::Lazy; use std::collections::HashMap; use std::env; use std::str::FromStr; +use once_cell::sync::Lazy; + +use crate::*; + /// TEST_RUNTIME is the runtime used for running tests. pub static TEST_RUNTIME: Lazy = Lazy::new(|| { tokio::runtime::Builder::new_multi_thread() diff --git a/core/src/raw/tests/write.rs b/core/src/raw/tests/write.rs index 511d5f143e58..d41ac28a0739 100644 --- a/core/src/raw/tests/write.rs +++ b/core/src/raw/tests/write.rs @@ -15,9 +15,12 @@ // specific language governing permissions and limitations // under the License. -use bytes::{Bytes, BytesMut}; -use rand::{thread_rng, RngCore}; -use sha2::{Digest, Sha256}; +use bytes::Bytes; +use bytes::BytesMut; +use rand::thread_rng; +use rand::RngCore; +use sha2::Digest; +use sha2::Sha256; /// WriteAction represents a read action. #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/core/src/services/alluxio/backend.rs b/core/src/services/alluxio/backend.rs index 64db4461f26a..8cbf902d41c0 100644 --- a/core/src/services/alluxio/backend.rs +++ b/core/src/services/alluxio/backend.rs @@ -24,12 +24,12 @@ use async_trait::async_trait; use log::debug; use serde::Deserialize; -use crate::raw::*; -use crate::*; - +use super::core::AlluxioCore; +use super::lister::AlluxioLister; use super::writer::AlluxioWriter; use super::writer::AlluxioWriters; -use super::{core::AlluxioCore, lister::AlluxioLister}; +use crate::raw::*; +use crate::*; /// Config for alluxio services support. #[derive(Default, Deserialize)] @@ -198,8 +198,6 @@ impl Accessor for AlluxioBackend { read: true, write: true, - /// https://github.com/Alluxio/alluxio/issues/8212 - write_can_append: false, write_can_multi: true, create_dir: true, diff --git a/core/src/services/alluxio/core.rs b/core/src/services/alluxio/core.rs index a68e0bcdc1ce..111f35718631 100644 --- a/core/src/services/alluxio/core.rs +++ b/core/src/services/alluxio/core.rs @@ -18,19 +18,17 @@ use std::fmt::Debug; use std::fmt::Formatter; -use http::Request; - use http::header::RANGE; +use http::Request; use http::Response; use http::StatusCode; +use serde::Deserialize; +use serde::Serialize; -use serde::{Deserialize, Serialize}; - +use super::error::parse_error; use crate::raw::*; use crate::*; -use super::error::parse_error; - #[derive(Debug, Serialize)] struct CreateFileRequest { #[serde(skip_serializing_if = "Option::is_none")] diff --git a/core/src/services/alluxio/error.rs b/core/src/services/alluxio/error.rs index 0f19d7a2978a..d07fece3103c 100644 --- a/core/src/services/alluxio/error.rs +++ b/core/src/services/alluxio/error.rs @@ -62,10 +62,11 @@ pub async fn parse_error(resp: Response) -> Result { #[cfg(test)] mod tests { - use super::*; use futures::stream; use http::StatusCode; + use super::*; + /// Error response example is from https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html #[tokio::test] async fn test_parse_error() { diff --git a/core/src/services/alluxio/writer.rs b/core/src/services/alluxio/writer.rs index 404304d84466..a45fdbdf7984 100644 --- a/core/src/services/alluxio/writer.rs +++ b/core/src/services/alluxio/writer.rs @@ -23,13 +23,11 @@ use std::task::Poll; use async_trait::async_trait; use futures::future::BoxFuture; +use super::core::AlluxioCore; use crate::raw::oio::WriteBuf; use crate::raw::*; - use crate::*; -use super::core::AlluxioCore; - pub type AlluxioWriters = AlluxioWriter; pub struct AlluxioWriter { diff --git a/core/src/services/azfile/backend.rs b/core/src/services/azfile/backend.rs index 3b87cb1f095a..e28e1acd6351 100644 --- a/core/src/services/azfile/backend.rs +++ b/core/src/services/azfile/backend.rs @@ -27,14 +27,13 @@ use reqsign::AzureStorageConfig; use reqsign::AzureStorageLoader; use reqsign::AzureStorageSigner; -use crate::raw::*; -use crate::services::azfile::lister::AzfileLister; -use crate::*; - use super::core::AzfileCore; use super::error::parse_error; use super::writer::AzfileWriter; use super::writer::AzfileWriters; +use crate::raw::*; +use crate::services::azfile::lister::AzfileLister; +use crate::*; /// Default endpoint of Azure File services. const DEFAULT_AZFILE_ENDPOINT_SUFFIX: &str = "file.core.windows.net"; diff --git a/core/src/services/azfile/lister.rs b/core/src/services/azfile/lister.rs index cdd8fc980b11..bb9f8f73b492 100644 --- a/core/src/services/azfile/lister.rs +++ b/core/src/services/azfile/lister.rs @@ -22,11 +22,10 @@ use http::StatusCode; use quick_xml::de::from_str; use serde::Deserialize; -use crate::raw::*; -use crate::*; - use super::core::AzfileCore; use super::error::parse_error; +use crate::raw::*; +use crate::*; pub struct AzfileLister { core: Arc, diff --git a/core/src/services/azfile/writer.rs b/core/src/services/azfile/writer.rs index 4f903a9b22a9..e6e199997f67 100644 --- a/core/src/services/azfile/writer.rs +++ b/core/src/services/azfile/writer.rs @@ -20,11 +20,10 @@ use std::sync::Arc; use async_trait::async_trait; use http::StatusCode; -use crate::raw::*; -use crate::*; - use super::core::AzfileCore; use super::error::parse_error; +use crate::raw::*; +use crate::*; pub type AzfileWriters = oio::TwoWaysWriter, oio::AppendObjectWriter>; diff --git a/core/src/services/cloudflare_kv/error.rs b/core/src/services/cloudflare_kv/error.rs index 10f4c4aaabf7..eb323f9ed2ce 100644 --- a/core/src/services/cloudflare_kv/error.rs +++ b/core/src/services/cloudflare_kv/error.rs @@ -18,17 +18,15 @@ use bytes::Buf; use http::Response; use http::StatusCode; +use serde_json::de; +use super::backend::CfKvError; +use super::backend::CfKvResponse; use crate::raw::*; use crate::Error; use crate::ErrorKind; use crate::Result; -use serde_json::de; - -use super::backend::CfKvError; -use super::backend::CfKvResponse; - /// Parse error response into Error. pub(crate) async fn parse_error(resp: Response) -> Result { let (parts, body) = resp.into_parts(); diff --git a/core/src/services/d1/backend.rs b/core/src/services/d1/backend.rs index 15e8d2854dda..5555c6bd57e2 100644 --- a/core/src/services/d1/backend.rs +++ b/core/src/services/d1/backend.rs @@ -25,14 +25,13 @@ use http::Request; use http::StatusCode; use serde_json::Value; +use super::error::parse_error; +use super::model::D1Response; use crate::raw::adapters::kv; use crate::raw::*; use crate::ErrorKind; use crate::*; -use super::error::parse_error; -use super::model::D1Response; - #[doc = include_str!("docs.md")] #[derive(Default)] pub struct D1Builder { diff --git a/core/src/services/d1/error.rs b/core/src/services/d1/error.rs index 2a2f75de49bc..96ac072e004e 100644 --- a/core/src/services/d1/error.rs +++ b/core/src/services/d1/error.rs @@ -18,17 +18,15 @@ use bytes::Buf; use http::Response; use http::StatusCode; +use serde_json::de; +use super::model::D1Error; +use super::model::D1Response; use crate::raw::*; use crate::Error; use crate::ErrorKind; use crate::Result; -use serde_json::de; - -use super::model::D1Error; -use super::model::D1Response; - /// Parse error response into Error. pub async fn parse_error(resp: Response) -> Result { let (parts, body) = resp.into_parts(); diff --git a/core/src/services/d1/model.rs b/core/src/services/d1/model.rs index c086af0d52f4..fee83bb13cbd 100644 --- a/core/src/services/d1/model.rs +++ b/core/src/services/d1/model.rs @@ -15,12 +15,16 @@ // specific language governing permissions and limitations // under the License. -use crate::Error; -use bytes::Bytes; -use serde::{Deserialize, Serialize}; -use serde_json::{Map, Value}; use std::fmt::Debug; +use bytes::Bytes; +use serde::Deserialize; +use serde::Serialize; +use serde_json::Map; +use serde_json::Value; + +use crate::Error; + /// response data from d1 #[derive(Deserialize, Debug)] pub struct D1Response { diff --git a/core/src/services/dbfs/backend.rs b/core/src/services/dbfs/backend.rs index 8da90e2b773c..4d85c3aadffc 100644 --- a/core/src/services/dbfs/backend.rs +++ b/core/src/services/dbfs/backend.rs @@ -25,14 +25,13 @@ use http::StatusCode; use log::debug; use serde::Deserialize; -use crate::raw::*; -use crate::*; - use super::core::DbfsCore; use super::error::parse_error; use super::lister::DbfsLister; use super::reader::DbfsReader; use super::writer::DbfsWriter; +use crate::raw::*; +use crate::*; /// [Dbfs](https://docs.databricks.com/api/azure/workspace/dbfs)'s REST API support. #[doc = include_str!("docs.md")] diff --git a/core/src/services/dbfs/core.rs b/core/src/services/dbfs/core.rs index 44e20e571099..80541d31e46c 100644 --- a/core/src/services/dbfs/core.rs +++ b/core/src/services/dbfs/core.rs @@ -26,11 +26,10 @@ use http::Response; use http::StatusCode; use serde_json::json; +use super::error::parse_error; use crate::raw::*; use crate::*; -use super::error::parse_error; - pub struct DbfsCore { pub root: String, pub endpoint: String, diff --git a/core/src/services/dbfs/lister.rs b/core/src/services/dbfs/lister.rs index 254afdc5806f..e86dd3381045 100644 --- a/core/src/services/dbfs/lister.rs +++ b/core/src/services/dbfs/lister.rs @@ -21,12 +21,11 @@ use async_trait::async_trait; use http::StatusCode; use serde::Deserialize; +use super::error::parse_error; use crate::raw::*; use crate::services::dbfs::core::DbfsCore; use crate::*; -use super::error::parse_error; - pub struct DbfsLister { core: Arc, path: String, diff --git a/core/src/services/dbfs/reader.rs b/core/src/services/dbfs/reader.rs index a74ddf71987e..1cc56ea89289 100644 --- a/core/src/services/dbfs/reader.rs +++ b/core/src/services/dbfs/reader.rs @@ -31,7 +31,6 @@ use futures::future::BoxFuture; use serde::Deserialize; use super::core::DbfsCore; - use crate::raw::*; use crate::*; diff --git a/core/src/services/dbfs/writer.rs b/core/src/services/dbfs/writer.rs index 04dbe4611812..f2db1124f4ff 100644 --- a/core/src/services/dbfs/writer.rs +++ b/core/src/services/dbfs/writer.rs @@ -20,13 +20,12 @@ use std::sync::Arc; use async_trait::async_trait; use http::StatusCode; +use super::error::parse_error; use crate::raw::oio::WriteBuf; use crate::raw::*; use crate::services::dbfs::core::DbfsCore; use crate::*; -use super::error::parse_error; - pub struct DbfsWriter { core: Arc, path: String, diff --git a/core/src/services/dropbox/backend.rs b/core/src/services/dropbox/backend.rs index 6aef1c9f792b..78a552141e64 100644 --- a/core/src/services/dropbox/backend.rs +++ b/core/src/services/dropbox/backend.rs @@ -26,13 +26,12 @@ use http::StatusCode; use once_cell::sync::Lazy; use serde::Deserialize; -use crate::raw::*; -use crate::services::dropbox::error::DropboxErrorResponse; -use crate::*; - use super::core::DropboxCore; use super::error::parse_error; use super::writer::DropboxWriter; +use crate::raw::*; +use crate::services::dropbox::error::DropboxErrorResponse; +use crate::*; static BACKOFF: Lazy = Lazy::new(|| { ExponentialBuilder::default() diff --git a/core/src/services/fs/lister.rs b/core/src/services/fs/lister.rs index 0dd3dcf56efc..c101c08d6b4f 100644 --- a/core/src/services/fs/lister.rs +++ b/core/src/services/fs/lister.rs @@ -18,7 +18,9 @@ use std::fs::FileType; use std::path::Path; use std::path::PathBuf; -use std::task::{ready, Context, Poll}; +use std::task::ready; +use std::task::Context; +use std::task::Poll; use async_trait::async_trait; use futures::future::BoxFuture; diff --git a/core/src/services/ftp/backend.rs b/core/src/services/ftp/backend.rs index 23570ac464e3..c5ad50f05ea5 100644 --- a/core/src/services/ftp/backend.rs +++ b/core/src/services/ftp/backend.rs @@ -28,6 +28,7 @@ use futures::AsyncRead; use futures::AsyncReadExt; use http::Uri; use log::debug; +use serde::Deserialize; use suppaftp::async_native_tls::TlsConnector; use suppaftp::list::File; use suppaftp::types::FileType; @@ -46,8 +47,6 @@ use crate::raw::*; use crate::services::ftp::writer::FtpWriters; use crate::*; -use serde::Deserialize; - /// Config for Ftpservices support. #[derive(Default, Deserialize)] #[serde(default)] diff --git a/core/src/services/ftp/lister.rs b/core/src/services/ftp/lister.rs index aa9a902bff4c..099fee930bac 100644 --- a/core/src/services/ftp/lister.rs +++ b/core/src/services/ftp/lister.rs @@ -17,7 +17,8 @@ use std::str; use std::str::FromStr; -use std::task::{Context, Poll}; +use std::task::Context; +use std::task::Poll; use std::vec::IntoIter; use async_trait::async_trait; diff --git a/core/src/services/gridfs/backend.rs b/core/src/services/gridfs/backend.rs index 606b464d3793..a98924214614 100644 --- a/core/src/services/gridfs/backend.rs +++ b/core/src/services/gridfs/backend.rs @@ -15,12 +15,17 @@ // specific language governing permissions and limitations // under the License. +use std::fmt::Debug; +use std::fmt::Formatter; + use async_trait::async_trait; -use futures::{AsyncWriteExt, StreamExt}; +use futures::AsyncWriteExt; +use futures::StreamExt; use mongodb::bson::doc; -use mongodb::options::{ClientOptions, GridFsBucketOptions, GridFsFindOptions}; +use mongodb::options::ClientOptions; +use mongodb::options::GridFsBucketOptions; +use mongodb::options::GridFsFindOptions; use mongodb::GridFsBucket; -use std::fmt::{Debug, Formatter}; use tokio::sync::OnceCell; use crate::raw::adapters::kv; diff --git a/core/src/services/hdfs/lister.rs b/core/src/services/hdfs/lister.rs index 50ba0ba4eab8..404d159f5c5a 100644 --- a/core/src/services/hdfs/lister.rs +++ b/core/src/services/hdfs/lister.rs @@ -15,8 +15,10 @@ // specific language governing permissions and limitations // under the License. +use std::task::Context; +use std::task::Poll; + use async_trait::async_trait; -use std::task::{Context, Poll}; use crate::raw::*; use crate::EntryMode; diff --git a/core/src/services/http/backend.rs b/core/src/services/http/backend.rs index b10eba4a80eb..7e1b8b3346bb 100644 --- a/core/src/services/http/backend.rs +++ b/core/src/services/http/backend.rs @@ -27,13 +27,12 @@ use http::Request; use http::Response; use http::StatusCode; use log::debug; +use serde::Deserialize; use super::error::parse_error; use crate::raw::*; use crate::*; -use serde::Deserialize; - /// Config for Http service support. #[derive(Default, Deserialize)] #[serde(default)] diff --git a/core/src/services/libsql/backend.rs b/core/src/services/libsql/backend.rs index 6c078b4416c2..805bbce8ebc8 100644 --- a/core/src/services/libsql/backend.rs +++ b/core/src/services/libsql/backend.rs @@ -21,21 +21,28 @@ use std::str; use async_trait::async_trait; use bytes::Bytes; -use hrana_client_proto::pipeline::{ - ClientMsg, Response, ServerMsg, StreamExecuteReq, StreamExecuteResult, StreamRequest, - StreamResponse, StreamResponseError, StreamResponseOk, -}; +use hrana_client_proto::pipeline::ClientMsg; +use hrana_client_proto::pipeline::Response; +use hrana_client_proto::pipeline::ServerMsg; +use hrana_client_proto::pipeline::StreamExecuteReq; +use hrana_client_proto::pipeline::StreamExecuteResult; +use hrana_client_proto::pipeline::StreamRequest; +use hrana_client_proto::pipeline::StreamResponse; +use hrana_client_proto::pipeline::StreamResponseError; +use hrana_client_proto::pipeline::StreamResponseOk; use hrana_client_proto::Error as PipelineError; -use hrana_client_proto::{Stmt, StmtResult, Value}; -use http::{Request, Uri}; +use hrana_client_proto::Stmt; +use hrana_client_proto::StmtResult; +use hrana_client_proto::Value; +use http::Request; +use http::Uri; use serde::Deserialize; +use super::error::parse_error; use crate::raw::adapters::kv; use crate::raw::*; use crate::*; -use super::error::parse_error; - /// Config for Libsqlservices support. #[derive(Default, Deserialize)] #[serde(default)] diff --git a/core/src/services/mongodb/backend.rs b/core/src/services/mongodb/backend.rs index cafed8fb3efb..76bdfd0116b1 100644 --- a/core/src/services/mongodb/backend.rs +++ b/core/src/services/mongodb/backend.rs @@ -15,11 +15,15 @@ // specific language governing permissions and limitations // under the License. +use std::fmt::Debug; +use std::fmt::Formatter; + use async_trait::async_trait; +use mongodb::bson::doc; use mongodb::bson::Binary; -use mongodb::bson::{doc, Document}; -use mongodb::options::{ClientOptions, UpdateOptions}; -use std::fmt::{Debug, Formatter}; +use mongodb::bson::Document; +use mongodb::options::ClientOptions; +use mongodb::options::UpdateOptions; use tokio::sync::OnceCell; use crate::raw::adapters::kv; diff --git a/core/src/services/mysql/backend.rs b/core/src/services/mysql/backend.rs index e3b5af5b6bc0..cdc4dd95988a 100644 --- a/core/src/services/mysql/backend.rs +++ b/core/src/services/mysql/backend.rs @@ -86,7 +86,6 @@ impl MysqlBuilder { /// - `mysql://user:password@localhost:3306/db` /// /// For more information, please refer to [mysql client](https://dev.mysql.com/doc/refman/8.0/en/connecting-using-uri-or-key-value-pairs.html) - /// pub fn connection_string(&mut self, v: &str) -> &mut Self { if !v.is_empty() { self.config.connection_string = Some(v.to_string()); diff --git a/core/src/services/oss/core.rs b/core/src/services/oss/core.rs index c90439de1d33..fad417c4c79f 100644 --- a/core/src/services/oss/core.rs +++ b/core/src/services/oss/core.rs @@ -15,6 +15,11 @@ // specific language governing permissions and limitations // under the License. +use std::fmt::Debug; +use std::fmt::Formatter; +use std::fmt::Write; +use std::time::Duration; + use bytes::Bytes; use http::header::CACHE_CONTROL; use http::header::CONTENT_DISPOSITION; @@ -32,10 +37,6 @@ use reqsign::AliyunLoader; use reqsign::AliyunOssSigner; use serde::Deserialize; use serde::Serialize; -use std::fmt::Debug; -use std::fmt::Formatter; -use std::fmt::Write; -use std::time::Duration; use crate::raw::*; use crate::*; diff --git a/core/src/services/sftp/backend.rs b/core/src/services/sftp/backend.rs index 47d680ef24df..69630025c797 100644 --- a/core/src/services/sftp/backend.rs +++ b/core/src/services/sftp/backend.rs @@ -30,6 +30,7 @@ use openssh::SessionBuilder; use openssh_sftp_client::file::TokioCompatFile; use openssh_sftp_client::Sftp; use openssh_sftp_client::SftpOptions; +use serde::Deserialize; use super::error::is_not_found; use super::error::is_sftp_protocol_error; @@ -38,8 +39,6 @@ use super::writer::SftpWriter; use crate::raw::*; use crate::*; -use serde::Deserialize; - /// Config for Sftpservices support. #[derive(Default, Deserialize)] #[serde(default)] diff --git a/core/src/services/sftp/lister.rs b/core/src/services/sftp/lister.rs index eeac58af8246..14d0b4843f8c 100644 --- a/core/src/services/sftp/lister.rs +++ b/core/src/services/sftp/lister.rs @@ -16,7 +16,9 @@ // under the License. use std::pin::Pin; -use std::task::{ready, Context, Poll}; +use std::task::ready; +use std::task::Context; +use std::task::Poll; use async_trait::async_trait; use futures::StreamExt; diff --git a/core/src/services/sqlite/backend.rs b/core/src/services/sqlite/backend.rs index 1d6a5743228f..6cf2df81d4f3 100644 --- a/core/src/services/sqlite/backend.rs +++ b/core/src/services/sqlite/backend.rs @@ -20,7 +20,8 @@ use std::fmt::Debug; use std::fmt::Formatter; use async_trait::async_trait; -use rusqlite::{params, Connection}; +use rusqlite::params; +use rusqlite::Connection; use serde::Deserialize; use tokio::task; diff --git a/core/src/services/swift/error.rs b/core/src/services/swift/error.rs index 48c482ca55da..836787ec0029 100644 --- a/core/src/services/swift/error.rs +++ b/core/src/services/swift/error.rs @@ -15,7 +15,8 @@ // specific language governing permissions and limitations // under the License. -use bytes::{Buf, Bytes}; +use bytes::Buf; +use bytes::Bytes; use http::Response; use http::StatusCode; use quick_xml::de; diff --git a/core/src/types/operator/operator.rs b/core/src/types/operator/operator.rs index 4461edce8cc1..0d24728f5734 100644 --- a/core/src/types/operator/operator.rs +++ b/core/src/types/operator/operator.rs @@ -26,7 +26,8 @@ use futures::TryStreamExt; use super::BlockingOperator; use crate::operator_futures::*; -use crate::raw::oio::{ReadExt, WriteExt}; +use crate::raw::oio::ReadExt; +use crate::raw::oio::WriteExt; use crate::raw::*; use crate::*; diff --git a/core/src/types/scheme.rs b/core/src/types/scheme.rs index f0bf62b73a12..54ea475f8e39 100644 --- a/core/src/types/scheme.rs +++ b/core/src/types/scheme.rs @@ -158,7 +158,7 @@ impl Scheme { /// /// let enabled_schemes = Scheme::enabled(); /// if !enabled_schemes.contains(&Scheme::Memory) { - /// panic!("s3 support is not enabled") + /// panic!("s3 support is not enabled") /// } /// ``` pub fn enabled() -> HashSet { diff --git a/core/tests/behavior/blocking_copy.rs b/core/tests/behavior/blocking_copy.rs index 6a6165f26023..5d4a1a45a2ab 100644 --- a/core/tests/behavior/blocking_copy.rs +++ b/core/tests/behavior/blocking_copy.rs @@ -16,7 +16,8 @@ // under the License. use anyhow::Result; -use sha2::{Digest, Sha256}; +use sha2::Digest; +use sha2::Sha256; use crate::*; diff --git a/core/tests/behavior/blocking_rename.rs b/core/tests/behavior/blocking_rename.rs index f61f9401e60b..378299ecad48 100644 --- a/core/tests/behavior/blocking_rename.rs +++ b/core/tests/behavior/blocking_rename.rs @@ -16,7 +16,8 @@ // under the License. use anyhow::Result; -use sha2::{Digest, Sha256}; +use sha2::Digest; +use sha2::Sha256; use crate::*; diff --git a/core/tests/behavior/copy.rs b/core/tests/behavior/copy.rs index f5fffd09462e..5a46776f7fcc 100644 --- a/core/tests/behavior/copy.rs +++ b/core/tests/behavior/copy.rs @@ -16,7 +16,8 @@ // under the License. use anyhow::Result; -use sha2::{Digest, Sha256}; +use sha2::Digest; +use sha2::Sha256; use crate::*; diff --git a/core/tests/behavior/fuzz.rs b/core/tests/behavior/fuzz.rs index 772a2c181a3b..cc97c0ea4c85 100644 --- a/core/tests/behavior/fuzz.rs +++ b/core/tests/behavior/fuzz.rs @@ -19,7 +19,8 @@ use std::io::SeekFrom; use std::vec; use anyhow::Result; -use opendal::raw::tests::{ReadAction, ReadChecker}; +use opendal::raw::tests::ReadAction; +use opendal::raw::tests::ReadChecker; use opendal::raw::BytesRange; use crate::*; @@ -110,25 +111,8 @@ pub async fn test_fuzz_issue_2717(op: Operator) -> Result<()> { /// FuzzInput { /// path: "06ae5d93-c0e9-43f2-ae5a-225cfaaa40a0", /// size: 1, -/// range: BytesRange( -/// Some( -/// 0, -/// ), -/// None, -/// ), -/// actions: [ -/// Seek( -/// Current( -/// 1, -/// ), -/// ), -/// Next, -/// Seek( -/// End( -/// -1, -/// ), -/// ), -/// ], +/// range: BytesRange(Some(0), None), +/// actions: [Seek(Current(1)), Next, Seek(End(-1))], /// } /// ``` pub async fn test_fuzz_pr_3395_case_1(op: Operator) -> Result<()> { @@ -148,26 +132,8 @@ pub async fn test_fuzz_pr_3395_case_1(op: Operator) -> Result<()> { /// FuzzInput { /// path: "e6056989-7c7c-4075-b975-5ae380884333", /// size: 1, -/// range: BytesRange( -/// Some( -/// 0, -/// ), -/// None, -/// ), -/// actions: [ -/// Next, -/// Seek( -/// Current( -/// 1, -/// ), -/// ), -/// Next, -/// Seek( -/// End( -/// 0, -/// ), -/// ), -/// ], +/// range: BytesRange(Some(0), None), +/// actions: [Next, Seek(Current(1)), Next, Seek(End(0))], /// } /// ``` pub async fn test_fuzz_pr_3395_case_2(op: Operator) -> Result<()> { diff --git a/core/tests/behavior/rename.rs b/core/tests/behavior/rename.rs index 29dd3de6ae0d..eb0a7447756f 100644 --- a/core/tests/behavior/rename.rs +++ b/core/tests/behavior/rename.rs @@ -16,7 +16,8 @@ // under the License. use anyhow::Result; -use sha2::{Digest, Sha256}; +use sha2::Digest; +use sha2::Sha256; use crate::*; diff --git a/core/tests/behavior/utils.rs b/core/tests/behavior/utils.rs index 60302a91a4fc..0bb0ed607f10 100644 --- a/core/tests/behavior/utils.rs +++ b/core/tests/behavior/utils.rs @@ -26,14 +26,13 @@ use futures::Future; use libtest_mimic::Failed; use libtest_mimic::Trial; use log::debug; +use opendal::raw::tests::TEST_RUNTIME; use opendal::*; use rand::distributions::uniform::SampleRange; use rand::prelude::*; use sha2::Digest; use sha2::Sha256; -use opendal::raw::tests::TEST_RUNTIME; - pub fn gen_bytes_with_range(range: impl SampleRange) -> (Vec, usize) { let mut rng = thread_rng();