Trait spacetimedb_commitlog::repo::Repo

source ·
pub trait Repo: Clone {
    type Segment: Read + Write + FileLike;

    // Required methods
    fn create_segment(&self, offset: u64) -> Result<Self::Segment>;
    fn open_segment(&self, offset: u64) -> Result<Self::Segment>;
    fn remove_segment(&self, offset: u64) -> Result<()>;
    fn existing_offsets(&self) -> Result<Vec<u64>>;
}
Expand description

A repository of log segments.

This is mainly an internal trait to allow testing against an in-memory representation.

Required Associated Types§

source

type Segment: Read + Write + FileLike

The type of log segments managed by this repo, which must behave like a file.

Required Methods§

source

fn create_segment(&self, offset: u64) -> Result<Self::Segment>

Create a new segment with the minimum transaction offset offset.

This must create the segment atomically, and return io::ErrorKind::AlreadyExists if the segment already exists.

It is permissible, however, to successfully return the new segment if it is completely empty (i.e. create_segment_writer did not previously succeed in writing the segment header).

source

fn open_segment(&self, offset: u64) -> Result<Self::Segment>

Open an existing segment at the minimum transaction offset offset.

Must return io::ErrorKind::NotFound if a segment with the given offset does not exist.

The method does not guarantee that the segment is non-empty – this case will be caught by [open_segment_writer] and open_segment_reader respectively.

source

fn remove_segment(&self, offset: u64) -> Result<()>

Remove the segment at the minimum transaction offset offset.

Return io::ErrorKind::NotFound if no such segment exists.

source

fn existing_offsets(&self) -> Result<Vec<u64>>

Traverse all segments in this repository and return list of their offsets, sorted in ascending order.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Repo for Fs