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 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 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§