From 3e2bc37d0eaa2ba8a08db150990abbb50c93f9ff Mon Sep 17 00:00:00 2001 From: meteorgan Date: Wed, 4 Dec 2024 17:19:56 +0800 Subject: [PATCH] fix some CR comments --- core/src/layers/capability_check.rs | 17 +++++++---------- core/src/layers/complete.rs | 4 ++-- core/src/layers/correctness_check.rs | 12 ++++-------- core/src/layers/mod.rs | 4 ++-- core/src/types/operator/builder.rs | 2 +- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/core/src/layers/capability_check.rs b/core/src/layers/capability_check.rs index 40ae15d1bf88..1ca1ffa994be 100644 --- a/core/src/layers/capability_check.rs +++ b/core/src/layers/capability_check.rs @@ -16,10 +16,7 @@ // under the License. use crate::layers::correctness_check::new_unsupported_args_error; -use crate::raw::{ - Access, AccessorInfo, Layer, LayeredAccess, OpDelete, OpList, OpRead, OpStat, OpWrite, - Operation, RpDelete, RpList, RpRead, RpStat, RpWrite, -}; +use crate::raw::*; use std::fmt::{Debug, Formatter}; use std::sync::Arc; @@ -42,24 +39,24 @@ use std::sync::Arc; /// # examples /// /// ```no_run -/// # use opendal::layers::CapabilityChecker; +/// # use opendal::layers::CapabilityCheckLayer; /// # use opendal::services; /// # use opendal::Operator; /// # use opendal::Result; /// # use opendal::Scheme; /// /// # fn main() -> Result<()> { -/// use opendal::layers::CapabilityChecker; +/// use opendal::layers::CapabilityCheckLayer; /// let _ = Operator::new(services::Memory::default())? -/// .layer(CapabilityChecker) +/// .layer(CapabilityCheckLayer) /// .finish(); /// Ok(()) /// # } /// ``` #[derive(Default)] -pub struct CapabilityChecker; +pub struct CapabilityCheckLayer; -impl Layer for CapabilityChecker { +impl Layer for CapabilityCheckLayer { type LayeredAccess = CapabilityAccessor; fn layer(&self, inner: A) -> Self::LayeredAccess { @@ -313,7 +310,7 @@ mod tests { fn new_test_operator(capability: Capability) -> Operator { let srv = MockService { capability }; - Operator::from_inner(Arc::new(srv)).layer(CapabilityChecker) + Operator::from_inner(Arc::new(srv)).layer(CapabilityCheckLayer) } #[tokio::test] diff --git a/core/src/layers/complete.rs b/core/src/layers/complete.rs index 98290ba8678e..bc06549014c4 100644 --- a/core/src/layers/complete.rs +++ b/core/src/layers/complete.rs @@ -136,7 +136,7 @@ impl CompleteAccessor { return Ok(RpCreateDir::default()); } - unreachable!("with correctness check, we cannot reach here") + return self.inner.create_dir(path, args).await; } fn complete_blocking_create_dir(&self, path: &str, args: OpCreateDir) -> Result { @@ -151,7 +151,7 @@ impl CompleteAccessor { return Ok(RpCreateDir::default()); } - unreachable!("with correctness check, we cannot reach here") + return self.inner.blocking_create_dir(path, args); } async fn complete_stat(&self, path: &str, args: OpStat) -> Result { diff --git a/core/src/layers/correctness_check.rs b/core/src/layers/correctness_check.rs index 15eea6022deb..0de038bab0d9 100644 --- a/core/src/layers/correctness_check.rs +++ b/core/src/layers/correctness_check.rs @@ -18,11 +18,7 @@ use std::fmt::{Debug, Formatter}; use std::sync::Arc; -use crate::raw::{ - Access, AccessorInfo, Layer, LayeredAccess, OpBatch, OpCopy, OpCreateDir, OpDelete, OpList, - OpPresign, OpRead, OpRename, OpStat, OpWrite, Operation, RpBatch, RpCopy, RpCreateDir, - RpDelete, RpList, RpPresign, RpRead, RpRename, RpStat, RpWrite, -}; +use crate::raw::*; use crate::{Error, ErrorKind}; /// Add a correctness capability check layer for every operation @@ -40,9 +36,9 @@ use crate::{Error, ErrorKind}; /// for example, when calling `write_with_append`, but `append` is not supported by the underlying /// service, an `Unsupported` error is returned. without this check, undesired data may be written. #[derive(Default)] -pub struct CorrectnessChecker; +pub struct CorrectnessCheckLayer; -impl Layer for CorrectnessChecker { +impl Layer for CorrectnessCheckLayer { type LayeredAccess = CorrectnessAccessor; fn layer(&self, inner: A) -> Self::LayeredAccess { @@ -427,7 +423,7 @@ mod tests { fn new_test_operator(capability: Capability) -> Operator { let srv = MockService { capability }; - Operator::from_inner(Arc::new(srv)).layer(CorrectnessChecker) + Operator::from_inner(Arc::new(srv)).layer(CorrectnessCheckLayer) } #[tokio::test] diff --git a/core/src/layers/mod.rs b/core/src/layers/mod.rs index c46b4ec7dfbf..0ac8f5f67abe 100644 --- a/core/src/layers/mod.rs +++ b/core/src/layers/mod.rs @@ -115,6 +115,6 @@ pub use self::dtrace::DtraceLayer; pub mod observe; mod correctness_check; -pub(crate) use correctness_check::CorrectnessChecker; +pub(crate) use correctness_check::CorrectnessCheckLayer; mod capability_check; -pub use capability_check::CapabilityChecker; +pub use capability_check::CapabilityCheckLayer; diff --git a/core/src/types/operator/builder.rs b/core/src/types/operator/builder.rs index f8349ae2c26c..4393cd5e0206 100644 --- a/core/src/types/operator/builder.rs +++ b/core/src/types/operator/builder.rs @@ -472,7 +472,7 @@ impl OperatorBuilder { OperatorBuilder { accessor } .layer(ErrorContextLayer) .layer(CompleteLayer) - .layer(CorrectnessChecker) + .layer(CorrectnessCheckLayer) } /// Create a new layer with static dispatch.