Trait PipeLog

Source
pub trait PipeLog: Sized {
    // Required methods
    fn read_bytes(&self, handle: FileBlockHandle) -> Result<Vec<u8>>;
    fn append<T: ReactiveBytes + ?Sized>(
        &self,
        queue: LogQueue,
        bytes: &mut T,
    ) -> Result<FileBlockHandle>;
    fn sync(&self, queue: LogQueue) -> Result<()>;
    fn file_span(&self, queue: LogQueue) -> (FileSeq, FileSeq);
    fn total_size(&self, queue: LogQueue) -> usize;
    fn rotate(&self, queue: LogQueue) -> Result<()>;
    fn purge_to(&self, file_id: FileId) -> Result<usize>;

    // Provided method
    fn file_at(&self, queue: LogQueue, position: f64) -> FileSeq { ... }
}
Expand description

A PipeLog serves reads and writes over multiple queues of log files.

§Safety

The pipe will panic if it encounters an unrecoverable failure. Otherwise the operations on it should be atomic, i.e. failed operation will not affect other ones, and user can still use it afterwards without breaking consistency.

Required Methods§

Source

fn read_bytes(&self, handle: FileBlockHandle) -> Result<Vec<u8>>

Reads some bytes from the specified position.

Source

fn append<T: ReactiveBytes + ?Sized>( &self, queue: LogQueue, bytes: &mut T, ) -> Result<FileBlockHandle>

Appends some bytes to the specified log queue. Returns file position of the written bytes.

Source

fn sync(&self, queue: LogQueue) -> Result<()>

Synchronizes all buffered writes.

This operation might incurs a great latency overhead. It’s advised to call it once every batch of writes.

Source

fn file_span(&self, queue: LogQueue) -> (FileSeq, FileSeq)

Returns the smallest and largest file sequence number, still in use, of the specified log queue.

Source

fn total_size(&self, queue: LogQueue) -> usize

Returns total size of the specified log queue.

Source

fn rotate(&self, queue: LogQueue) -> Result<()>

Rotates a new log file for the specified log queue.

Implementation should be atomic under error conditions but not necessarily panic-safe.

Source

fn purge_to(&self, file_id: FileId) -> Result<usize>

Deletes all log files smaller than the specified file ID. The scope is limited to the log queue of file_id.

Returns the number of deleted files.

Provided Methods§

Source

fn file_at(&self, queue: LogQueue, position: f64) -> FileSeq

Returns the oldest file ID that is newer than position% of all files.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§