chore: satisfy warnings about async fn in traits
This commit is contained in:
@@ -3,18 +3,24 @@ use opendal::{Buffer, Error, ErrorKind, FuturesAsyncReader, Operator};
|
||||
|
||||
#[extension(pub trait OperatorExt)]
|
||||
impl Operator {
|
||||
async fn read_if_exists(&self, path: &str) -> Result<Option<Buffer>, Error> {
|
||||
fn read_if_exists(
|
||||
&self,
|
||||
path: &str,
|
||||
) -> impl Future<Output = Result<Option<Buffer>, Error>> + Send {
|
||||
async {
|
||||
match self.read(path).await {
|
||||
Ok(buffer) => Ok(Some(buffer)),
|
||||
Err(error) if matches!(error.kind(), ErrorKind::NotFound) => Ok(None),
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn async_reader_if_exists(
|
||||
fn async_reader_if_exists(
|
||||
&self,
|
||||
path: &str,
|
||||
) -> Result<Option<FuturesAsyncReader>, Error> {
|
||||
) -> impl Future<Output = Result<Option<FuturesAsyncReader>, Error>> + Send {
|
||||
async {
|
||||
let reader = self.reader(path).await?;
|
||||
match reader.into_futures_async_read(..).await {
|
||||
Ok(reader) => Ok(Some(reader)),
|
||||
@@ -22,4 +28,5 @@ impl Operator {
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user