Skip to main content

Source

Trait Source 

Source
pub trait Source {
    // Required methods
    fn read_at(&self, offset: u64, buf: &mut [u8]) -> Result<()>;
    fn len(&self) -> Result<u64>;

    // Provided methods
    fn is_empty(&self) -> Result<bool> { ... }
    fn accounts_for_wal(&self) -> bool { ... }
}

Required Methods§

Source

fn read_at(&self, offset: u64, buf: &mut [u8]) -> Result<()>

Read exactly buf.len() bytes at offset. Reading past the end is an error; short reads are never returned.

Source

fn len(&self) -> Result<u64>

Size in bytes.

Provided Methods§

Source

fn is_empty(&self) -> Result<bool>

Source

fn accounts_for_wal(&self) -> bool

Whether this source has already accounted for a write-ahead log.

A wal mode database is only complete in its main file once the log has been checkpointed into it, and bytes alone cannot say whether that happened. A source that knows, because it looked next to the file or because it reads the log itself, says so here; everything else stays conservative and a wal mode database read through it is refused rather than silently truncated to an older version.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Source for FileSource

Available on Unix only.
Source§

impl Source for SliceSource<'_>

Source§

impl<S: Source, W: Source> Source for WalSource<S, W>