diff --git a/core/src/types/delete/deleter.rs b/core/src/types/delete/deleter.rs index 834ff8152672..74163809ee53 100644 --- a/core/src/types/delete/deleter.rs +++ b/core/src/types/delete/deleter.rs @@ -67,12 +67,12 @@ use std::pin::pin; /// ```rust /// use opendal::Operator; /// use opendal::Result; -/// use futures::stream; +/// use futures::{stream, Sink}; /// use futures::SinkExt; /// /// async fn example(op: Operator) -> Result<()> { /// let mut sink = op.deleter().await?.into_sink(); -/// sink.send_all(&mut stream::iter(vec!["path/to/file"])).await?; +/// sink.send("path/to/file").await?; /// sink.close().await?; /// Ok(()) /// } @@ -210,7 +210,7 @@ impl Deleter { } /// Convert the deleter into a sink. - pub fn into_sink(self) -> FuturesDeleteSink { + pub fn into_sink(self) -> FuturesDeleteSink { FuturesDeleteSink::new(self) } } diff --git a/core/src/types/delete/futures_delete_sink.rs b/core/src/types/delete/futures_delete_sink.rs index cce811e73366..458481b87c74 100644 --- a/core/src/types/delete/futures_delete_sink.rs +++ b/core/src/types/delete/futures_delete_sink.rs @@ -18,12 +18,14 @@ use crate::raw::*; use crate::*; use futures::Sink; +use std::marker::PhantomData; use std::pin::Pin; use std::task::{ready, Context, Poll}; /// FuturesDeleteSink is a sink that generated by [`Deleter`] -pub struct FuturesDeleteSink { +pub struct FuturesDeleteSink { state: State, + _phantom: PhantomData, } enum State { @@ -33,16 +35,17 @@ enum State { Close(BoxedStaticFuture<(Deleter, Result<()>)>), } -impl FuturesDeleteSink { +impl FuturesDeleteSink { #[inline] pub(super) fn new(deleter: Deleter) -> Self { Self { state: State::Idle(Some(deleter)), + _phantom: PhantomData, } } } -impl Sink for FuturesDeleteSink { +impl Sink for FuturesDeleteSink { type Error = Error; fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { diff --git a/core/src/types/delete/input.rs b/core/src/types/delete/input.rs index 9c4b056fd697..ae136a6ade09 100644 --- a/core/src/types/delete/input.rs +++ b/core/src/types/delete/input.rs @@ -29,7 +29,7 @@ pub struct DeleteInput { } /// IntoDeleteInput is a helper trait that makes it easier for users to play with `Deleter`. -pub trait IntoDeleteInput: Send + Sync { +pub trait IntoDeleteInput: Send + Sync + Unpin { /// Convert `self` into a `DeleteInput`. fn into_delete_input(self) -> DeleteInput; }