Skip to content

Commit ad0eed2

Browse files
committed
feat(core/types): change oio::BlockingReader to Arc<dyn oio::BlockingRead>
1 parent 63e061a commit ad0eed2

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

core/src/types/blocking_read/blocking_reader.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818
use std::collections::Bound;
1919
use std::ops::Range;
2020
use std::ops::RangeBounds;
21+
use std::sync::Arc;
2122

2223
use bytes::Buf;
2324
use bytes::BufMut;
2425

25-
use crate::raw::oio::BlockingRead;
2626
use crate::raw::*;
2727
use crate::*;
2828

2929
/// BlockingReader is designed to read data from given path in an blocking
3030
/// manner.
3131
pub struct BlockingReader {
32-
pub(crate) inner: oio::BlockingReader,
32+
pub(crate) inner: Arc<dyn oio::BlockingRead>,
3333
}
3434

3535
impl BlockingReader {
@@ -43,7 +43,7 @@ impl BlockingReader {
4343
pub(crate) fn create(acc: Accessor, path: &str, op: OpRead) -> crate::Result<Self> {
4444
let (_, r) = acc.blocking_read(path, op)?;
4545

46-
Ok(BlockingReader { inner: r })
46+
Ok(BlockingReader { inner: Arc::new(r) })
4747
}
4848

4949
/// Read give range from reader into [`Buffer`].

core/src/types/blocking_read/std_bytes_iterator.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
use std::io;
19+
use std::sync::Arc;
1920

2021
use bytes::Buf;
2122
use bytes::Bytes;
@@ -28,7 +29,7 @@ use crate::raw::*;
2829
///
2930
/// StdIterator also implements [`Send`] and [`Sync`].
3031
pub struct StdBytesIterator {
31-
inner: oio::BlockingReader,
32+
inner: Arc<dyn oio::BlockingRead>,
3233
offset: u64,
3334
size: u64,
3435
cap: usize,
@@ -39,7 +40,7 @@ pub struct StdBytesIterator {
3940
impl StdBytesIterator {
4041
/// NOTE: don't allow users to create StdIterator directly.
4142
#[inline]
42-
pub(crate) fn new(r: oio::BlockingReader, range: std::ops::Range<u64>) -> Self {
43+
pub(crate) fn new(r: Arc<dyn oio::BlockingRead>, range: std::ops::Range<u64>) -> Self {
4344
StdBytesIterator {
4445
inner: r,
4546
offset: range.start,

core/src/types/blocking_read/std_reader.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use std::io::Read;
2121
use std::io::Seek;
2222
use std::io::SeekFrom;
2323
use std::ops::Range;
24+
use std::sync::Arc;
2425

2526
use bytes::Buf;
2627

@@ -33,7 +34,7 @@ use crate::*;
3334
///
3435
/// StdReader also implements [`Send`] and [`Sync`].
3536
pub struct StdReader {
36-
inner: oio::BlockingReader,
37+
inner: Arc<dyn oio::BlockingRead>,
3738
offset: u64,
3839
size: u64,
3940
cap: usize,
@@ -45,7 +46,7 @@ pub struct StdReader {
4546
impl StdReader {
4647
/// NOTE: don't allow users to create StdReader directly.
4748
#[inline]
48-
pub(super) fn new(r: oio::BlockingReader, range: Range<u64>) -> Self {
49+
pub(super) fn new(r: Arc<dyn oio::BlockingRead>, range: Range<u64>) -> Self {
4950
StdReader {
5051
inner: r,
5152
offset: range.start,

0 commit comments

Comments
 (0)