pub struct Deleter { /* private fields */ }
Expand description
Deleter is designed to continuously remove content from storage.
It leverages batch deletion capabilities provided by storage services for efficient removal.
§Usage
Deleter
provides several ways to delete files:
§Direct Deletion
Use the delete
method to remove a single file:
use opendal::Operator;
use opendal::Result;
async fn example(op: Operator) -> Result<()> {
let mut d = op.deleter().await?;
d.delete("path/to/file").await?;
d.close().await?;
Ok(())
}
Delete multiple files via a stream:
use futures::stream;
use opendal::Operator;
use opendal::Result;
async fn example(op: Operator) -> Result<()> {
let mut d = op.deleter().await?;
d.delete_stream(stream::iter(vec!["path/to/file"])).await?;
d.close().await?;
Ok(())
}
§Using as a Sink
Deleter can be used as a Sink for file deletion:
use futures::stream;
use futures::Sink;
use futures::SinkExt;
use opendal::Operator;
use opendal::Result;
async fn example(op: Operator) -> Result<()> {
let mut sink = op.deleter().await?.into_sink();
sink.send("path/to/file").await?;
sink.close().await?;
Ok(())
}
Implementations§
Source§impl Deleter
impl Deleter
Sourcepub async fn delete(&mut self, input: impl IntoDeleteInput) -> Result<()>
pub async fn delete(&mut self, input: impl IntoDeleteInput) -> Result<()>
Delete a path.
Sourcepub async fn delete_iter<I, D>(&mut self, iter: I) -> Result<()>where
I: IntoIterator<Item = D>,
D: IntoDeleteInput,
pub async fn delete_iter<I, D>(&mut self, iter: I) -> Result<()>where
I: IntoIterator<Item = D>,
D: IntoDeleteInput,
Delete an infallible iterator of paths.
Also see:
Deleter::delete_try_iter
: delete a fallible iterator of paths.Deleter::delete_stream
: delete an infallible stream of paths.Deleter::delete_try_stream
: delete a fallible stream of paths.
Sourcepub async fn delete_try_iter<I, D>(&mut self, try_iter: I) -> Result<()>
pub async fn delete_try_iter<I, D>(&mut self, try_iter: I) -> Result<()>
Delete a fallible iterator of paths.
Also see:
Deleter::delete_iter
: delete an infallible iterator of paths.Deleter::delete_stream
: delete an infallible stream of paths.Deleter::delete_try_stream
: delete a fallible stream of paths.
Sourcepub async fn delete_stream<S, D>(&mut self, stream: S) -> Result<()>where
S: Stream<Item = D>,
D: IntoDeleteInput,
pub async fn delete_stream<S, D>(&mut self, stream: S) -> Result<()>where
S: Stream<Item = D>,
D: IntoDeleteInput,
Delete an infallible stream of paths.
Also see:
Deleter::delete_iter
: delete an infallible iterator of paths.Deleter::delete_try_iter
: delete a fallible iterator of paths.Deleter::delete_try_stream
: delete a fallible stream of paths.
Sourcepub async fn delete_try_stream<S, D>(&mut self, try_stream: S) -> Result<()>
pub async fn delete_try_stream<S, D>(&mut self, try_stream: S) -> Result<()>
Delete a fallible stream of paths.
Also see:
Deleter::delete_iter
: delete an infallible iterator of paths.Deleter::delete_try_iter
: delete a fallible iterator of paths.Deleter::delete_stream
: delete an infallible stream of paths.
Sourcepub async fn flush(&mut self) -> Result<usize>
pub async fn flush(&mut self) -> Result<usize>
Flush the deleter, returns the number of deleted paths.
Sourcepub async fn close(&mut self) -> Result<()>
pub async fn close(&mut self) -> Result<()>
Close the deleter, this will flush the deleter and wait until all paths are deleted.
Sourcepub fn into_sink<T: IntoDeleteInput>(self) -> FuturesDeleteSink<T>
pub fn into_sink<T: IntoDeleteInput>(self) -> FuturesDeleteSink<T>
Convert the deleter into a sink.
Auto Trait Implementations§
impl Freeze for Deleter
impl !RefUnwindSafe for Deleter
impl Send for Deleter
impl Sync for Deleter
impl Unpin for Deleter
impl !UnwindSafe for Deleter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Decompress response bodies. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more