You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/03/11 07:55:07 UTC
(opendal) 21/24: Don't impl io traits on dyn reader
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch read-async-trait
in repository https://gitbox.apache.org/repos/asf/opendal.git
commit 718edef03f7cb52387de12f63d54e7c6fcc15737
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Mon Mar 11 15:46:07 2024 +0800
Don't impl io traits on dyn reader
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
core/src/raw/oio/read/api.rs | 28 +---------------------------
core/src/types/reader.rs | 4 ++--
2 files changed, 3 insertions(+), 29 deletions(-)
diff --git a/core/src/raw/oio/read/api.rs b/core/src/raw/oio/read/api.rs
index c5c704cf86..d766a21492 100644
--- a/core/src/raw/oio/read/api.rs
+++ b/core/src/raw/oio/read/api.rs
@@ -23,7 +23,7 @@ use bytes::Bytes;
use futures::Future;
use tokio::io::ReadBuf;
-use crate::raw::{format_std_io_error, BoxedFuture};
+use crate::raw::BoxedFuture;
use crate::*;
/// PageOperation is the name for APIs of lister.
@@ -301,29 +301,3 @@ impl<T: BlockingRead + ?Sized> BlockingRead for Box<T> {
(**self).next()
}
}
-
-impl io::Read for dyn BlockingRead {
- #[inline]
- fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
- let this: &mut dyn BlockingRead = &mut *self;
- this.read(buf).map_err(format_std_io_error)
- }
-}
-
-impl io::Seek for dyn BlockingRead {
- #[inline]
- fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
- let this: &mut dyn BlockingRead = &mut *self;
- this.seek(pos).map_err(format_std_io_error)
- }
-}
-
-impl Iterator for dyn BlockingRead {
- type Item = Result<Bytes>;
-
- #[inline]
- fn next(&mut self) -> Option<Self::Item> {
- let this: &mut dyn BlockingRead = &mut *self;
- this.next()
- }
-}
diff --git a/core/src/types/reader.rs b/core/src/types/reader.rs
index a9a516d41a..db3e379962 100644
--- a/core/src/types/reader.rs
+++ b/core/src/types/reader.rs
@@ -343,14 +343,14 @@ impl oio::BlockingRead for BlockingReader {
impl io::Read for BlockingReader {
#[inline]
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
- self.inner.read(buf)
+ self.inner.read(buf).map_err(format_std_io_error)
}
}
impl io::Seek for BlockingReader {
#[inline]
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
- self.inner.seek(pos)
+ self.inner.seek(pos).map_err(format_std_io_error)
}
}