diff --git a/core/src/layers/await_tree.rs b/core/src/layers/await_tree.rs index 7a641ed80c8..4fb680ef528 100644 --- a/core/src/layers/await_tree.rs +++ b/core/src/layers/await_tree.rs @@ -18,9 +18,6 @@ use await_tree::InstrumentAwait; use futures::Future; use futures::FutureExt; -use oio::ListOperation; -use oio::ReadOperation; -use oio::WriteOperation; use crate::raw::*; use crate::*; @@ -182,7 +179,7 @@ impl oio::Read for AwaitTreeWrapper { async fn read(&mut self) -> Result { self.inner .read() - .instrument_await(format!("opendal::{}", ReadOperation::Read)) + .instrument_await(format!("opendal::{}", Operation::ReaderRead)) .await } } @@ -197,19 +194,19 @@ impl oio::Write for AwaitTreeWrapper { fn write(&mut self, bs: Buffer) -> impl Future> + MaybeSend { self.inner .write(bs) - .instrument_await(format!("opendal::{}", WriteOperation::Write.into_static())) + .instrument_await(format!("opendal::{}", Operation::WriterWrite.into_static())) } fn abort(&mut self) -> impl Future> + MaybeSend { self.inner .abort() - .instrument_await(format!("opendal::{}", WriteOperation::Abort.into_static())) + .instrument_await(format!("opendal::{}", Operation::WriterAbort.into_static())) } fn close(&mut self) -> impl Future> + MaybeSend { self.inner .close() - .instrument_await(format!("opendal::{}", WriteOperation::Close.into_static())) + .instrument_await(format!("opendal::{}", Operation::WriterClose.into_static())) } } @@ -227,7 +224,7 @@ impl oio::List for AwaitTreeWrapper { async fn next(&mut self) -> Result> { self.inner .next() - .instrument_await(format!("opendal::{}", ListOperation::Next)) + .instrument_await(format!("opendal::{}", Operation::ListerNext)) .await } } diff --git a/core/src/layers/error_context.rs b/core/src/layers/error_context.rs index 78ab14db3ba..43a8fc224e8 100644 --- a/core/src/layers/error_context.rs +++ b/core/src/layers/error_context.rs @@ -21,9 +21,6 @@ use std::sync::Arc; use futures::TryFutureExt; -use crate::raw::oio::ListOperation; -use crate::raw::oio::ReadOperation; -use crate::raw::oio::WriteOperation; use crate::raw::*; use crate::*; @@ -358,7 +355,7 @@ impl oio::Read for ErrorContextWrapper { bs }) .map_err(|err| { - err.with_operation(ReadOperation::Read) + err.with_operation(Operation::ReaderRead) .with_context("service", self.scheme) .with_context("path", &self.path) .with_context("range", self.range.to_string()) @@ -376,7 +373,7 @@ impl oio::BlockingRead for ErrorContextWrapper { bs }) .map_err(|err| { - err.with_operation(ReadOperation::BlockingRead) + err.with_operation(Operation::BlockingReaderRead) .with_context("service", self.scheme) .with_context("path", &self.path) .with_context("range", self.range.to_string()) @@ -395,7 +392,7 @@ impl oio::Write for ErrorContextWrapper { self.processed += size as u64; }) .map_err(|err| { - err.with_operation(WriteOperation::Write) + err.with_operation(Operation::WriterWrite) .with_context("service", self.scheme) .with_context("path", &self.path) .with_context("size", size.to_string()) @@ -405,7 +402,7 @@ impl oio::Write for ErrorContextWrapper { async fn close(&mut self) -> Result<()> { self.inner.close().await.map_err(|err| { - err.with_operation(WriteOperation::Close) + err.with_operation(Operation::WriterClose) .with_context("service", self.scheme) .with_context("path", &self.path) .with_context("written", self.processed.to_string()) @@ -414,7 +411,7 @@ impl oio::Write for ErrorContextWrapper { async fn abort(&mut self) -> Result<()> { self.inner.abort().await.map_err(|err| { - err.with_operation(WriteOperation::Abort) + err.with_operation(Operation::WriterAbort) .with_context("service", self.scheme) .with_context("path", &self.path) .with_context("processed", self.processed.to_string()) @@ -431,7 +428,7 @@ impl oio::BlockingWrite for ErrorContextWrapper { self.processed += size as u64; }) .map_err(|err| { - err.with_operation(WriteOperation::BlockingWrite) + err.with_operation(Operation::BlockingWriterWrite) .with_context("service", self.scheme) .with_context("path", &self.path) .with_context("size", size.to_string()) @@ -441,7 +438,7 @@ impl oio::BlockingWrite for ErrorContextWrapper { fn close(&mut self) -> Result<()> { self.inner.close().map_err(|err| { - err.with_operation(WriteOperation::BlockingClose) + err.with_operation(Operation::BlockingWriterClose) .with_context("service", self.scheme) .with_context("path", &self.path) .with_context("written", self.processed.to_string()) @@ -459,7 +456,7 @@ impl oio::List for ErrorContextWrapper { bs }) .map_err(|err| { - err.with_operation(ListOperation::Next) + err.with_operation(Operation::ListerNext) .with_context("service", self.scheme) .with_context("path", &self.path) .with_context("listed", self.processed.to_string()) @@ -476,7 +473,7 @@ impl oio::BlockingList for ErrorContextWrapper { bs }) .map_err(|err| { - err.with_operation(ListOperation::BlockingNext) + err.with_operation(Operation::BlockingListerNext) .with_context("service", self.scheme) .with_context("path", &self.path) .with_context("listed", self.processed.to_string()) diff --git a/core/src/layers/fastrace.rs b/core/src/layers/fastrace.rs index 3af23c4be5a..caae7b939ac 100644 --- a/core/src/layers/fastrace.rs +++ b/core/src/layers/fastrace.rs @@ -22,9 +22,6 @@ use std::sync::Arc; use fastrace::prelude::*; use futures::FutureExt; -use crate::raw::oio::ListOperation; -use crate::raw::oio::ReadOperation; -use crate::raw::oio::WriteOperation; use crate::raw::*; use crate::*; @@ -301,7 +298,7 @@ impl oio::Read for FastraceWrapper { impl oio::BlockingRead for FastraceWrapper { fn read(&mut self) -> Result { let _g = self.span.set_local_parent(); - let _span = LocalSpan::enter_with_local_parent(ReadOperation::BlockingRead.into_static()); + let _span = LocalSpan::enter_with_local_parent(Operation::BlockingReaderRead.into_static()); self.inner.read() } } @@ -309,19 +306,19 @@ impl oio::BlockingRead for FastraceWrapper { impl oio::Write for FastraceWrapper { fn write(&mut self, bs: Buffer) -> impl Future> + MaybeSend { let _g = self.span.set_local_parent(); - let _span = LocalSpan::enter_with_local_parent(WriteOperation::Write.into_static()); + let _span = LocalSpan::enter_with_local_parent(Operation::WriterWrite.into_static()); self.inner.write(bs) } fn abort(&mut self) -> impl Future> + MaybeSend { let _g = self.span.set_local_parent(); - let _span = LocalSpan::enter_with_local_parent(WriteOperation::Abort.into_static()); + let _span = LocalSpan::enter_with_local_parent(Operation::WriterAbort.into_static()); self.inner.abort() } fn close(&mut self) -> impl Future> + MaybeSend { let _g = self.span.set_local_parent(); - let _span = LocalSpan::enter_with_local_parent(WriteOperation::Close.into_static()); + let _span = LocalSpan::enter_with_local_parent(Operation::WriterClose.into_static()); self.inner.close() } } @@ -329,13 +326,15 @@ impl oio::Write for FastraceWrapper { impl oio::BlockingWrite for FastraceWrapper { fn write(&mut self, bs: Buffer) -> Result<()> { let _g = self.span.set_local_parent(); - let _span = LocalSpan::enter_with_local_parent(WriteOperation::BlockingWrite.into_static()); + let _span = + LocalSpan::enter_with_local_parent(Operation::BlockingWriterWrite.into_static()); self.inner.write(bs) } fn close(&mut self) -> Result<()> { let _g = self.span.set_local_parent(); - let _span = LocalSpan::enter_with_local_parent(WriteOperation::BlockingClose.into_static()); + let _span = + LocalSpan::enter_with_local_parent(Operation::BlockingWriterClose.into_static()); self.inner.close() } } @@ -350,7 +349,7 @@ impl oio::List for FastraceWrapper { impl oio::BlockingList for FastraceWrapper { fn next(&mut self) -> Result> { let _g = self.span.set_local_parent(); - let _span = LocalSpan::enter_with_local_parent(ListOperation::BlockingNext.into_static()); + let _span = LocalSpan::enter_with_local_parent(Operation::BlockingListerNext.into_static()); self.inner.next() } } diff --git a/core/src/layers/logging.rs b/core/src/layers/logging.rs index b56f7164556..40294204f6b 100644 --- a/core/src/layers/logging.rs +++ b/core/src/layers/logging.rs @@ -28,8 +28,6 @@ use log::log; use log::trace; use log::Level; -use crate::raw::oio::ReadOperation; -use crate::raw::oio::WriteOperation; use crate::raw::*; use crate::*; @@ -988,7 +986,7 @@ impl oio::Read for LoggingReader { target: LOGGING_TARGET, "service={} operation={} path={} read={} -> read returns {}B", self.ctx.scheme, - ReadOperation::Read, + Operation::ReaderRead, self.path, self.read.load(Ordering::Relaxed), bs.remaining() @@ -1002,7 +1000,7 @@ impl oio::Read for LoggingReader { lvl, "service={} operation={} path={} read={} -> read failed: {}", self.ctx.scheme, - ReadOperation::Read, + Operation::ReaderRead, self.path, self.read.load(Ordering::Relaxed), self.ctx.error_print(&err), @@ -1024,7 +1022,7 @@ impl oio::BlockingRead for LoggingReader { target: LOGGING_TARGET, "service={} operation={} path={} read={} -> read returns {}B", self.ctx.scheme, - ReadOperation::BlockingRead, + Operation::BlockingReaderRead, self.path, self.read.load(Ordering::Relaxed), bs.remaining() @@ -1038,7 +1036,7 @@ impl oio::BlockingRead for LoggingReader { lvl, "service={} operation={} path={} read={} -> read failed: {}", self.ctx.scheme, - ReadOperation::BlockingRead, + Operation::BlockingReaderRead, self.path, self.read.load(Ordering::Relaxed), self.ctx.error_print(&err), @@ -1081,7 +1079,7 @@ impl oio::Write for LoggingWriter { target: LOGGING_TARGET, "service={} operation={} path={} written={}B -> data write {}B", self.ctx.scheme, - WriteOperation::Write, + Operation::WriterWrite, self.path, self.written, size, @@ -1095,7 +1093,7 @@ impl oio::Write for LoggingWriter { lvl, "service={} operation={} path={} written={}B -> data write failed: {}", self.ctx.scheme, - WriteOperation::Write, + Operation::WriterWrite, self.path, self.written, self.ctx.error_print(&err), @@ -1113,7 +1111,7 @@ impl oio::Write for LoggingWriter { target: LOGGING_TARGET, "service={} operation={} path={} written={}B -> abort writer", self.ctx.scheme, - WriteOperation::Abort, + Operation::WriterAbort, self.path, self.written, ); @@ -1126,7 +1124,7 @@ impl oio::Write for LoggingWriter { lvl, "service={} operation={} path={} written={}B -> abort writer failed: {}", self.ctx.scheme, - WriteOperation::Abort, + Operation::WriterAbort, self.path, self.written, self.ctx.error_print(&err), @@ -1157,7 +1155,7 @@ impl oio::Write for LoggingWriter { lvl, "service={} operation={} path={} written={}B -> data close failed: {}", self.ctx.scheme, - WriteOperation::Close, + Operation::WriterClose, self.path, self.written, self.ctx.error_print(&err), @@ -1177,7 +1175,7 @@ impl oio::BlockingWrite for LoggingWriter { target: LOGGING_TARGET, "service={} operation={} path={} written={}B -> data write {}B", self.ctx.scheme, - WriteOperation::BlockingWrite, + Operation::BlockingWriterWrite, self.path, self.written, bs.len(), @@ -1191,7 +1189,7 @@ impl oio::BlockingWrite for LoggingWriter { lvl, "service={} operation={} path={} written={}B -> data write failed: {}", self.ctx.scheme, - WriteOperation::BlockingWrite, + Operation::BlockingWriterWrite, self.path, self.written, self.ctx.error_print(&err), @@ -1222,7 +1220,7 @@ impl oio::BlockingWrite for LoggingWriter { lvl, "service={} operation={} path={} written={}B -> data close failed: {}", self.ctx.scheme, - WriteOperation::BlockingClose, + Operation::BlockingWriterClose, self.path, self.written, self.ctx.error_print(&err), diff --git a/core/src/layers/prometheus.rs b/core/src/layers/prometheus.rs index 44bb2a5eb48..8eedb002750 100644 --- a/core/src/layers/prometheus.rs +++ b/core/src/layers/prometheus.rs @@ -31,8 +31,6 @@ use prometheus::register_int_counter_vec_with_registry; use prometheus::HistogramVec; use prometheus::Registry; -use crate::raw::oio::ReadOperation; -use crate::raw::oio::WriteOperation; use crate::raw::Access; use crate::raw::*; use crate::*; @@ -681,7 +679,7 @@ impl oio::Read for PrometheusMetricWrapper { async fn read(&mut self) -> Result { let labels = self.stats.generate_metric_label( self.scheme.into_static(), - ReadOperation::Read.into_static(), + Operation::ReaderRead.into_static(), &self.path, ); @@ -713,7 +711,7 @@ impl oio::BlockingRead for PrometheusMetricWrapper { fn read(&mut self) -> Result { let labels = self.stats.generate_metric_label( self.scheme.into_static(), - ReadOperation::BlockingRead.into_static(), + Operation::BlockingReaderRead.into_static(), &self.path, ); @@ -747,7 +745,7 @@ impl oio::Write for PrometheusMetricWrapper { let labels = self.stats.generate_metric_label( self.scheme.into_static(), - WriteOperation::Write.into_static(), + Operation::WriterWrite.into_static(), &self.path, ); @@ -777,7 +775,7 @@ impl oio::Write for PrometheusMetricWrapper { async fn abort(&mut self) -> Result<()> { let labels = self.stats.generate_metric_label( self.scheme.into_static(), - WriteOperation::Abort.into_static(), + Operation::WriterAbort.into_static(), &self.path, ); @@ -801,7 +799,7 @@ impl oio::Write for PrometheusMetricWrapper { async fn close(&mut self) -> Result<()> { let labels = self.stats.generate_metric_label( self.scheme.into_static(), - WriteOperation::Close.into_static(), + Operation::WriterClose.into_static(), &self.path, ); @@ -859,7 +857,7 @@ impl oio::BlockingWrite for PrometheusMetricWrapper { fn close(&mut self) -> Result<()> { let labels = self.stats.generate_metric_label( self.scheme.into_static(), - WriteOperation::BlockingClose.into_static(), + Operation::BlockingWriterClose.into_static(), &self.path, ); diff --git a/core/src/layers/prometheus_client.rs b/core/src/layers/prometheus_client.rs index b4f01244f2a..7ecee0eb7c0 100644 --- a/core/src/layers/prometheus_client.rs +++ b/core/src/layers/prometheus_client.rs @@ -31,8 +31,6 @@ use prometheus_client::metrics::histogram; use prometheus_client::metrics::histogram::Histogram; use prometheus_client::registry::Registry; -use crate::raw::oio::ReadOperation; -use crate::raw::oio::WriteOperation; use crate::raw::Access; use crate::raw::*; use crate::*; @@ -622,19 +620,19 @@ impl oio::Read for PrometheusMetricWrapper { Ok(bs) => { self.metrics.observe_bytes_total( self.scheme, - ReadOperation::Read.into_static(), + Operation::ReaderRead.into_static(), bs.remaining(), ); self.metrics.observe_request_duration( self.scheme, - ReadOperation::Read.into_static(), + Operation::ReaderRead.into_static(), start.elapsed(), ); Ok(bs) } Err(e) => { self.metrics - .increment_errors_total(ReadOperation::Read.into_static(), e.kind()); + .increment_errors_total(Operation::ReaderRead.into_static(), e.kind()); Err(e) } } @@ -649,19 +647,19 @@ impl oio::BlockingRead for PrometheusMetricWrapper { .map(|bs| { self.metrics.observe_bytes_total( self.scheme, - ReadOperation::BlockingRead.into_static(), + Operation::BlockingReaderRead.into_static(), bs.remaining(), ); self.metrics.observe_request_duration( self.scheme, - ReadOperation::BlockingRead.into_static(), + Operation::BlockingReaderRead.into_static(), start.elapsed(), ); bs }) .map_err(|e| { self.metrics - .increment_errors_total(ReadOperation::BlockingRead.into_static(), e.kind()); + .increment_errors_total(Operation::BlockingReaderRead.into_static(), e.kind()); e }) } @@ -678,18 +676,18 @@ impl oio::Write for PrometheusMetricWrapper { .map(|_| { self.metrics.observe_bytes_total( self.scheme, - WriteOperation::Write.into_static(), + Operation::WriterWrite.into_static(), size, ); self.metrics.observe_request_duration( self.scheme, - WriteOperation::Write.into_static(), + Operation::WriterWrite.into_static(), start.elapsed(), ); }) .map_err(|err| { self.metrics - .increment_errors_total(WriteOperation::Write.into_static(), err.kind()); + .increment_errors_total(Operation::WriterWrite.into_static(), err.kind()); err }) } @@ -703,13 +701,13 @@ impl oio::Write for PrometheusMetricWrapper { .map(|_| { self.metrics.observe_request_duration( self.scheme, - WriteOperation::Abort.into_static(), + Operation::WriterAbort.into_static(), start.elapsed(), ); }) .map_err(|err| { self.metrics - .increment_errors_total(WriteOperation::Abort.into_static(), err.kind()); + .increment_errors_total(Operation::WriterAbort.into_static(), err.kind()); err }) } @@ -723,13 +721,13 @@ impl oio::Write for PrometheusMetricWrapper { .map(|_| { self.metrics.observe_request_duration( self.scheme, - WriteOperation::Close.into_static(), + Operation::WriterClose.into_static(), start.elapsed(), ); }) .map_err(|err| { self.metrics - .increment_errors_total(WriteOperation::Close.into_static(), err.kind()); + .increment_errors_total(Operation::WriterClose.into_static(), err.kind()); err }) } @@ -745,18 +743,18 @@ impl oio::BlockingWrite for PrometheusMetricWrapper { .map(|_| { self.metrics.observe_bytes_total( self.scheme, - WriteOperation::BlockingWrite.into_static(), + Operation::BlockingWriterWrite.into_static(), size, ); self.metrics.observe_request_duration( self.scheme, - WriteOperation::BlockingWrite.into_static(), + Operation::BlockingWriterWrite.into_static(), start.elapsed(), ); }) .map_err(|err| { self.metrics.increment_errors_total( - WriteOperation::BlockingWrite.into_static(), + Operation::BlockingWriterWrite.into_static(), err.kind(), ); err @@ -771,13 +769,13 @@ impl oio::BlockingWrite for PrometheusMetricWrapper { .map(|_| { self.metrics.observe_request_duration( self.scheme, - WriteOperation::BlockingClose.into_static(), + Operation::BlockingWriterClose.into_static(), start.elapsed(), ); }) .map_err(|err| { self.metrics.increment_errors_total( - WriteOperation::BlockingClose.into_static(), + Operation::BlockingWriterClose.into_static(), err.kind(), ); err diff --git a/core/src/layers/timeout.rs b/core/src/layers/timeout.rs index b57ca854133..3adc6878532 100644 --- a/core/src/layers/timeout.rs +++ b/core/src/layers/timeout.rs @@ -19,9 +19,6 @@ use std::future::Future; use std::sync::Arc; use std::time::Duration; -use crate::raw::oio::ListOperation; -use crate::raw::oio::ReadOperation; -use crate::raw::oio::WriteOperation; use crate::raw::*; use crate::*; @@ -345,31 +342,31 @@ impl TimeoutWrapper { impl oio::Read for TimeoutWrapper { async fn read(&mut self) -> Result { let fut = self.inner.read(); - Self::io_timeout(self.timeout, ReadOperation::Read.into_static(), fut).await + Self::io_timeout(self.timeout, Operation::ReaderRead.into_static(), fut).await } } impl oio::Write for TimeoutWrapper { async fn write(&mut self, bs: Buffer) -> Result<()> { let fut = self.inner.write(bs); - Self::io_timeout(self.timeout, WriteOperation::Write.into_static(), fut).await + Self::io_timeout(self.timeout, Operation::WriterWrite.into_static(), fut).await } async fn close(&mut self) -> Result<()> { let fut = self.inner.close(); - Self::io_timeout(self.timeout, WriteOperation::Close.into_static(), fut).await + Self::io_timeout(self.timeout, Operation::WriterClose.into_static(), fut).await } async fn abort(&mut self) -> Result<()> { let fut = self.inner.abort(); - Self::io_timeout(self.timeout, WriteOperation::Abort.into_static(), fut).await + Self::io_timeout(self.timeout, Operation::WriterAbort.into_static(), fut).await } } impl oio::List for TimeoutWrapper { async fn next(&mut self) -> Result> { let fut = self.inner.next(); - Self::io_timeout(self.timeout, ListOperation::Next.into_static(), fut).await + Self::io_timeout(self.timeout, Operation::ListerNext.into_static(), fut).await } } diff --git a/core/src/raw/oio/list/api.rs b/core/src/raw/oio/list/api.rs index c071b7ed45f..836dd6053b1 100644 --- a/core/src/raw/oio/list/api.rs +++ b/core/src/raw/oio/list/api.rs @@ -15,8 +15,6 @@ // specific language governing permissions and limitations // under the License. -use std::fmt::Display; -use std::fmt::Formatter; use std::future::Future; use std::ops::DerefMut; @@ -24,40 +22,6 @@ use crate::raw::oio::Entry; use crate::raw::*; use crate::*; -/// PageOperation is the name for APIs of lister. -#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)] -#[non_exhaustive] -pub enum ListOperation { - /// Operation for [`List::next`] - Next, - /// Operation for [`BlockingList::next`] - BlockingNext, -} - -impl ListOperation { - /// Convert self into static str. - pub fn into_static(self) -> &'static str { - self.into() - } -} - -impl Display for ListOperation { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.into_static()) - } -} - -impl From for &'static str { - fn from(v: ListOperation) -> &'static str { - use ListOperation::*; - - match v { - Next => "List::next", - BlockingNext => "List::next", - } - } -} - /// The boxed version of [`List`] pub type Lister = Box; diff --git a/core/src/raw/oio/list/mod.rs b/core/src/raw/oio/list/mod.rs index 8460afb1a25..60b8de0d999 100644 --- a/core/src/raw/oio/list/mod.rs +++ b/core/src/raw/oio/list/mod.rs @@ -19,7 +19,6 @@ mod api; pub use api::BlockingList; pub use api::BlockingLister; pub use api::List; -pub use api::ListOperation; pub use api::Lister; mod page_list; diff --git a/core/src/raw/oio/read/api.rs b/core/src/raw/oio/read/api.rs index 3a003e6a320..e90328234fb 100644 --- a/core/src/raw/oio/read/api.rs +++ b/core/src/raw/oio/read/api.rs @@ -15,8 +15,6 @@ // specific language governing permissions and limitations // under the License. -use std::fmt::Display; -use std::fmt::Formatter; use std::mem; use std::ops::DerefMut; @@ -26,40 +24,6 @@ use futures::Future; use crate::raw::*; use crate::*; -/// PageOperation is the name for APIs of lister. -#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)] -#[non_exhaustive] -pub enum ReadOperation { - /// Operation for [`Read::read`] - Read, - /// Operation for [`BlockingRead::read`] - BlockingRead, -} - -impl ReadOperation { - /// Convert self into static str. - pub fn into_static(self) -> &'static str { - self.into() - } -} - -impl Display for ReadOperation { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.into_static()) - } -} - -impl From for &'static str { - fn from(v: ReadOperation) -> &'static str { - use ReadOperation::*; - - match v { - Read => "Reader::read", - BlockingRead => "BlockingReader::read", - } - } -} - /// Reader is a type erased [`Read`]. pub type Reader = Box; diff --git a/core/src/raw/oio/read/mod.rs b/core/src/raw/oio/read/mod.rs index 5ec4114c512..e8186f7c6ce 100644 --- a/core/src/raw/oio/read/mod.rs +++ b/core/src/raw/oio/read/mod.rs @@ -20,5 +20,4 @@ pub use api::BlockingRead; pub use api::BlockingReader; pub use api::Read; pub use api::ReadDyn; -pub use api::ReadOperation; pub use api::Reader; diff --git a/core/src/raw/oio/write/api.rs b/core/src/raw/oio/write/api.rs index 4ec53adab67..91d2b3cad9a 100644 --- a/core/src/raw/oio/write/api.rs +++ b/core/src/raw/oio/write/api.rs @@ -15,59 +15,12 @@ // specific language governing permissions and limitations // under the License. -use std::fmt::Display; -use std::fmt::Formatter; use std::future::Future; use std::ops::DerefMut; use crate::raw::*; use crate::*; -/// WriteOperation is the name for APIs of Writer. -#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)] -#[non_exhaustive] -pub enum WriteOperation { - /// Operation for [`Write::write`] - Write, - /// Operation for [`Write::close`] - Close, - /// Operation for [`Write::abort`] - Abort, - - /// Operation for [`BlockingWrite::write`] - BlockingWrite, - /// Operation for [`BlockingWrite::close`] - BlockingClose, -} - -impl WriteOperation { - /// Convert self into static str. - pub fn into_static(self) -> &'static str { - self.into() - } -} - -impl Display for WriteOperation { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.into_static()) - } -} - -impl From for &'static str { - fn from(v: WriteOperation) -> &'static str { - use WriteOperation::*; - - match v { - Write => "Writer::write", - Close => "Writer::close", - Abort => "Writer::abort", - - BlockingWrite => "BlockingWriter::write", - BlockingClose => "BlockingWriter::close", - } - } -} - /// Writer is a type erased [`Write`] pub type Writer = Box; diff --git a/core/src/raw/oio/write/mod.rs b/core/src/raw/oio/write/mod.rs index 48a1334407e..bd1ae5ae958 100644 --- a/core/src/raw/oio/write/mod.rs +++ b/core/src/raw/oio/write/mod.rs @@ -19,7 +19,6 @@ mod api; pub use api::BlockingWrite; pub use api::BlockingWriter; pub use api::Write; -pub use api::WriteOperation; pub use api::Writer; mod multipart_write; diff --git a/core/src/raw/operation.rs b/core/src/raw/operation.rs index 03ea57c890b..d195cb57ac0 100644 --- a/core/src/raw/operation.rs +++ b/core/src/raw/operation.rs @@ -29,8 +29,16 @@ pub enum Operation { CreateDir, /// Operation for [`crate::raw::Access::read`] Read, + /// Operation for [`crate::raw::oio::Read::read`] + ReaderRead, /// Operation for [`crate::raw::Access::write`] Write, + /// Operation for [`crate::raw::oio::Write::write`] + WriterWrite, + /// Operation for [`crate::raw::oio::Write::close`] + WriterClose, + /// Operation for [`crate::raw::oio::Write::abort`] + WriterAbort, /// Operation for [`crate::raw::Access::copy`] Copy, /// Operation for [`crate::raw::Access::rename`] @@ -41,6 +49,8 @@ pub enum Operation { Delete, /// Operation for [`crate::raw::Access::list`] List, + /// Operation for [`crate::raw::oio::List::next`] + ListerNext, /// Operation for [`crate::raw::Access::batch`] Batch, /// Operation for [`crate::raw::Access::presign`] @@ -49,8 +59,14 @@ pub enum Operation { BlockingCreateDir, /// Operation for [`crate::raw::Access::blocking_read`] BlockingRead, + /// Operation for [`crate::raw::oio::BlockingRead::read`] + BlockingReaderRead, /// Operation for [`crate::raw::Access::blocking_write`] BlockingWrite, + /// Operation for [`crate::raw::oio::BlockingWrite::write`] + BlockingWriterWrite, + /// Operation for [`crate::raw::oio::BlockingWrite::close`] + BlockingWriterClose, /// Operation for [`crate::raw::Access::blocking_copy`] BlockingCopy, /// Operation for [`crate::raw::Access::blocking_rename`] @@ -61,6 +77,8 @@ pub enum Operation { BlockingDelete, /// Operation for [`crate::raw::Access::blocking_list`] BlockingList, + /// Operation for [`crate::raw::oio::BlockingList::next`] + BlockingListerNext, } impl Operation { @@ -82,22 +100,31 @@ impl From for &'static str { Operation::Info => "metadata", Operation::CreateDir => "create_dir", Operation::Read => "read", + Operation::ReaderRead => "Reader::read", Operation::Write => "write", + Operation::WriterWrite => "Writer::write", + Operation::WriterClose => "Writer::close", + Operation::WriterAbort => "Writer::abort", Operation::Copy => "copy", Operation::Rename => "rename", Operation::Stat => "stat", Operation::Delete => "delete", Operation::List => "list", + Operation::ListerNext => "List::next", Operation::Presign => "presign", Operation::Batch => "batch", Operation::BlockingCreateDir => "blocking_create_dir", Operation::BlockingRead => "blocking_read", + Operation::BlockingReaderRead => "BlockingReader::read", Operation::BlockingWrite => "blocking_write", + Operation::BlockingWriterWrite => "BlockingWriter::write", + Operation::BlockingWriterClose => "BlockingWriter::close", Operation::BlockingCopy => "blocking_copy", Operation::BlockingRename => "blocking_rename", Operation::BlockingStat => "blocking_stat", Operation::BlockingDelete => "blocking_delete", Operation::BlockingList => "blocking_list", + Operation::BlockingListerNext => "BlockingLister::next", } } }