Skip to main content

SpillFile

Trait SpillFile 

Source
pub trait SpillFile: Send + Sync {
    // Required methods
    fn size(&self) -> Option<u64>;
    fn read_stream(
        &self,
    ) -> Result<Pin<Box<dyn Stream<Item = Result<Bytes>> + Send>>>;
    fn open_writer(&self) -> Result<Box<dyn SpillWriter>>;

    // Provided methods
    fn path(&self) -> Option<&Path> { ... }
    fn open_async_writer<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncSpillWriter>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Abstraction over a spill file backend. Implementations handle their own quota enforcement and blocking concerns.

Required Methods§

Source

fn size(&self) -> Option<u64>

Returns current size in bytes if cheaply available.

Source

fn read_stream( &self, ) -> Result<Pin<Box<dyn Stream<Item = Result<Bytes>> + Send>>>

Returns file contents as an async stream of byte chunks.

Source

fn open_writer(&self) -> Result<Box<dyn SpillWriter>>

Opens a writer for appending data to this file.

Provided Methods§

Source

fn path(&self) -> Option<&Path>

Returns the OS path if this is a local file, None otherwise.

Source

fn open_async_writer<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncSpillWriter>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Opens an asynchronous writer for appending data to this file.

The default implementation adapts Self::open_writer for backwards compatibility. Backends with native asynchronous I/O should override this method to avoid blocking an async executor.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§