Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,18 @@ mod tests {
assert_eq!(1, size_of::<EntryMode>());
assert_eq!(24, size_of::<Scheme>());
}

/// This is used to make sure our public API implement Send + Sync
trait AssertSendSync: Send + Sync {}
impl AssertSendSync for Entry {}
impl AssertSendSync for Capability {}
impl AssertSendSync for Error {}
impl AssertSendSync for Reader {}
impl AssertSendSync for Writer {}
impl AssertSendSync for Lister {}
impl AssertSendSync for Operator {}
impl AssertSendSync for BlockingReader {}
impl AssertSendSync for BlockingWriter {}
impl AssertSendSync for BlockingLister {}
impl AssertSendSync for BlockingOperator {}
}
2 changes: 1 addition & 1 deletion core/src/raw/oio/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<P: Page> Page for Option<P> {
}

/// BlockingPage is the blocking version of [`Page`].
pub trait BlockingPage: 'static {
pub trait BlockingPage: Send + 'static {
/// Fetch a new page of [`Entry`]
///
/// `Ok(None)` means all pages have been returned. Any following call
Expand Down
10 changes: 10 additions & 0 deletions core/src/types/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ pub struct Lister {
fut: Option<BoxFuture<'static, (oio::Pager, Result<Option<Vec<oio::Entry>>>)>>,
}

/// # Safety
///
/// Lister will only be accessed by `&mut Self`
unsafe impl Sync for Lister {}

impl Lister {
/// Create a new lister.
pub(crate) fn new(pager: oio::Pager) -> Self {
Expand Down Expand Up @@ -166,6 +171,11 @@ pub struct BlockingLister {
buf: VecDeque<oio::Entry>,
}

/// # Safety
///
/// BlockingLister will only be accessed by `&mut Self`
unsafe impl Sync for BlockingLister {}

impl BlockingLister {
/// Create a new lister.
pub(crate) fn new(pager: oio::BlockingPager) -> Self {
Expand Down
5 changes: 5 additions & 0 deletions core/src/types/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ pub struct Writer {
state: State,
}

/// # Safety
///
/// Writer will only be accessed by `&mut Self`
unsafe impl Sync for Writer {}

impl Writer {
/// Create a new writer.
///
Expand Down