This is an automated email from the ASF dual-hosted git repository. Xuanwo pushed a commit to branch xuanwo/refactor-core-layers-inline-apply-service in repository https://gitbox.apache.org/repos/asf/opendal.git
commit 185bae5c68d0b15517a401d74907e41a8ac076fa Author: Xuanwo <[email protected]> AuthorDate: Mon Nov 23 20:39:07 2026 +0100 refactor(core): inline layer apply_service and narrow internal wrapper visibility --- core/core/src/layers/capability_override.rs | 12 +++--------- core/core/src/layers/error_context.rs | 12 +++--------- core/core/src/layers/simulate.rs | 22 ++++++++-------------- 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/core/core/src/layers/capability_override.rs b/core/core/src/layers/capability_override.rs index 31208c433e..e5fce333ee 100644 --- a/core/core/src/layers/capability_override.rs +++ b/core/core/src/layers/capability_override.rs @@ -87,20 +87,14 @@ impl CapabilityOverrideLayer { impl Layer for CapabilityOverrideLayer { fn apply_service(&self, inner: Servicer) -> Servicer { - Arc::new(self.layer(inner)) - } -} - -impl CapabilityOverrideLayer { - fn layer(&self, inner: Servicer) -> CapabilityOverrideService { - CapabilityOverrideService { + Arc::new(CapabilityOverrideService { inner, apply: self.apply.clone(), - } + }) } } -pub struct CapabilityOverrideService { +struct CapabilityOverrideService { inner: Servicer, apply: Arc<dyn Fn(Capability) -> Capability + Send + Sync>, } diff --git a/core/core/src/layers/error_context.rs b/core/core/src/layers/error_context.rs index 83086dd063..839ee45493 100644 --- a/core/core/src/layers/error_context.rs +++ b/core/core/src/layers/error_context.rs @@ -49,18 +49,12 @@ impl std::fmt::Debug for ErrorContextLayer { impl Layer for ErrorContextLayer { fn apply_service(&self, inner: Servicer) -> Servicer { - Arc::new(self.layer(inner)) - } -} - -impl ErrorContextLayer { - fn layer(&self, inner: Servicer) -> ErrorContextService { - ErrorContextService { inner } + Arc::new(ErrorContextService { inner }) } } /// Provide error context wrapper for backend. -pub struct ErrorContextService { +struct ErrorContextService { inner: Servicer, } @@ -221,7 +215,7 @@ impl Service for ErrorContextService { } } -pub struct ErrorContextWrapper<T> { +struct ErrorContextWrapper<T> { scheme: &'static str, path: String, inner: T, diff --git a/core/core/src/layers/simulate.rs b/core/core/src/layers/simulate.rs index 4ee0d2e44f..01c4606dac 100644 --- a/core/core/src/layers/simulate.rs +++ b/core/core/src/layers/simulate.rs @@ -111,21 +111,15 @@ impl SimulateLayer { impl Layer for SimulateLayer { fn apply_service(&self, srv: Servicer) -> Servicer { - Arc::new(self.layer(srv)) - } -} - -impl SimulateLayer { - fn layer(&self, srv: Servicer) -> SimulateService { - SimulateService { + Arc::new(SimulateService { srv, config: self.clone(), - } + }) } } /// Service that applies capability simulation. -pub struct SimulateService { +struct SimulateService { srv: Servicer, config: SimulateLayer, } @@ -431,14 +425,14 @@ impl Service for SimulateService { } } -pub type SimulateLister = FourWays< +type SimulateLister = FourWays< oio::Lister, ServicerFlatLister, PrefixLister<oio::Lister>, PrefixLister<ServicerFlatLister>, >; -pub struct SimulateReader { +struct SimulateReader { ctx: OperationContext, srv: Servicer, path: String, @@ -641,7 +635,7 @@ enum NextDir { Listing(PendingDir, oio::Lister), } -pub struct ServicerFlatLister { +struct ServicerFlatLister { ctx: OperationContext, srv: Servicer, directory_args: OpList, @@ -812,7 +806,7 @@ impl oio::List for ServicerFlatLister { } /// Deleter wrapper that simulates recursive deletion. -pub struct SimulateDeleter { +struct SimulateDeleter { ctx: OperationContext, srv: Servicer, config: SimulateLayer, @@ -820,7 +814,7 @@ pub struct SimulateDeleter { } impl SimulateDeleter { - pub fn new( + fn new( ctx: OperationContext, srv: Servicer, config: SimulateLayer,
