Skip to main content

ReplicationLog

Trait ReplicationLog 

Source
pub trait ReplicationLog {
    // Required methods
    fn append(&mut self, record: Vec<u8>) -> SyncResult<usize>;
    fn append_with_sequence(
        &mut self,
        record: Vec<u8>,
        sequence: u64,
    ) -> SyncResult<usize>;
    fn events_since(&self, index: usize) -> SyncResult<Vec<Vec<u8>>>;
    fn last_index(&self) -> SyncResult<usize>;
    fn len(&self) -> SyncResult<usize>;
    fn is_empty(&self) -> SyncResult<bool>;

    // Provided methods
    fn event_at_sequence(&self, _sequence: u64) -> SyncResult<Option<Vec<u8>>> { ... }
    fn events_page(
        &self,
        index: usize,
        max_records: usize,
        max_bytes: usize,
    ) -> SyncResult<Vec<Vec<u8>>> { ... }
    fn create_snapshot(&self) -> SyncResult<ReplicationSnapshot> { ... }
    fn restore_snapshot(
        &mut self,
        _snapshot: &ReplicationSnapshot,
    ) -> SyncResult<()> { ... }
}
Expand description

Replication log contract.

Required Methods§

Source

fn append(&mut self, record: Vec<u8>) -> SyncResult<usize>

Appends an unsequenced record and returns its one-based log index.

Source

fn append_with_sequence( &mut self, record: Vec<u8>, sequence: u64, ) -> SyncResult<usize>

Idempotently appends record at a source sequence.

Source

fn events_since(&self, index: usize) -> SyncResult<Vec<Vec<u8>>>

Returns payloads after the supplied zero-based log offset.

Source

fn last_index(&self) -> SyncResult<usize>

Returns the one-based final log index, or zero for an empty log.

Source

fn len(&self) -> SyncResult<usize>

Returns the number of records in the log.

Source

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

Reports whether the log contains no records.

Provided Methods§

Source

fn event_at_sequence(&self, _sequence: u64) -> SyncResult<Option<Vec<u8>>>

Returns the payload at a source sequence when sequence lookup is supported.

Source

fn events_page( &self, index: usize, max_records: usize, max_bytes: usize, ) -> SyncResult<Vec<Vec<u8>>>

Returns one payload page with bounded record count and payload bytes.

Compatibility providers may use the default full-read adapter. Durable providers should override this method to enforce both limits before materializing payloads. The default moves selected payloads without another deep copy, but cannot bound the allocation performed by events_since before selection.

Source

fn create_snapshot(&self) -> SyncResult<ReplicationSnapshot>

Creates a validated portable snapshot when supported.

Source

fn restore_snapshot( &mut self, _snapshot: &ReplicationSnapshot, ) -> SyncResult<()>

Atomically replaces log contents from a validated snapshot when supported.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§