Skip to main content

DetachedReader

Trait DetachedReader 

Source
pub trait DetachedReader: Send {
    // Required method
    fn read_detached(
        &mut self,
        from: &Path,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Record>, Error>> + Send>>;
}
Expand description

Async reads whose futures are detached from the store.

AsyncReader’s futures borrow &mut self, so one in-flight read holds the store’s exclusive borrow for the whole operation — a long-parked read stalls every other request. DetachedReader splits the phases: the store produces the future synchronously (&mut self, briefly), and the future resolves asynchronously with no borrow of the store, so many operations can be in flight at once.

Implementors typically clone an Arc of shared state into the future.

Required Methods§

Source

fn read_detached( &mut self, from: &Path, ) -> Pin<Box<dyn Future<Output = Result<Option<Record>, Error>> + Send>>

Begin a read; the returned future resolves independently.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> DetachedReader for &mut T
where T: DetachedReader + ?Sized,

Source§

fn read_detached( &mut self, from: &Path, ) -> Pin<Box<dyn Future<Output = Result<Option<Record>, Error>> + Send>>

Source§

impl<T> DetachedReader for Box<T>
where T: DetachedReader + ?Sized,

Source§

fn read_detached( &mut self, from: &Path, ) -> Pin<Box<dyn Future<Output = Result<Option<Record>, Error>> + Send>>

Implementors§