pub trait Storage<T>where
T: Entry,{
Show 19 methods
// Required methods
fn append_entry(&mut self, entry: T) -> StorageResult<u64>;
fn append_entries(&mut self, entries: Vec<T>) -> StorageResult<u64>;
fn append_on_prefix(
&mut self,
from_idx: u64,
entries: Vec<T>,
) -> StorageResult<u64>;
fn set_promise(&mut self, n_prom: Ballot) -> StorageResult<()>;
fn set_decided_idx(&mut self, ld: u64) -> StorageResult<()>;
fn get_decided_idx(&self) -> StorageResult<u64>;
fn set_accepted_round(&mut self, na: Ballot) -> StorageResult<()>;
fn get_accepted_round(&self) -> StorageResult<Option<Ballot>>;
fn get_entries(&self, from: u64, to: u64) -> StorageResult<Vec<T>>;
fn get_log_len(&self) -> StorageResult<u64>;
fn get_suffix(&self, from: u64) -> StorageResult<Vec<T>>;
fn get_promise(&self) -> StorageResult<Option<Ballot>>;
fn set_stopsign(&mut self, s: Option<StopSign>) -> StorageResult<()>;
fn get_stopsign(&self) -> StorageResult<Option<StopSign>>;
fn trim(&mut self, idx: u64) -> StorageResult<()>;
fn set_compacted_idx(&mut self, idx: u64) -> StorageResult<()>;
fn get_compacted_idx(&self) -> StorageResult<u64>;
fn set_snapshot(
&mut self,
snapshot: Option<T::Snapshot>,
) -> StorageResult<()>;
fn get_snapshot(&self) -> StorageResult<Option<T::Snapshot>>;
}
Expand description
Trait for implementing the storage backend of Sequence Paxos.
Required Methods§
Sourcefn append_entry(&mut self, entry: T) -> StorageResult<u64>
fn append_entry(&mut self, entry: T) -> StorageResult<u64>
Appends an entry to the end of the log and returns the log length.
Sourcefn append_entries(&mut self, entries: Vec<T>) -> StorageResult<u64>
fn append_entries(&mut self, entries: Vec<T>) -> StorageResult<u64>
Appends the entries of entries
to the end of the log and returns the log length.
Sourcefn append_on_prefix(
&mut self,
from_idx: u64,
entries: Vec<T>,
) -> StorageResult<u64>
fn append_on_prefix( &mut self, from_idx: u64, entries: Vec<T>, ) -> StorageResult<u64>
Appends the entries of entries
to the prefix from index from_index
in the log and returns the log length.
Sourcefn set_promise(&mut self, n_prom: Ballot) -> StorageResult<()>
fn set_promise(&mut self, n_prom: Ballot) -> StorageResult<()>
Sets the round that has been promised.
Sourcefn set_decided_idx(&mut self, ld: u64) -> StorageResult<()>
fn set_decided_idx(&mut self, ld: u64) -> StorageResult<()>
Sets the decided index in the log.
Sourcefn get_decided_idx(&self) -> StorageResult<u64>
fn get_decided_idx(&self) -> StorageResult<u64>
Returns the decided index in the log.
Sourcefn set_accepted_round(&mut self, na: Ballot) -> StorageResult<()>
fn set_accepted_round(&mut self, na: Ballot) -> StorageResult<()>
Sets the latest accepted round.
Sourcefn get_accepted_round(&self) -> StorageResult<Option<Ballot>>
fn get_accepted_round(&self) -> StorageResult<Option<Ballot>>
Returns the latest round in which entries have been accepted, returns None
if no
entries have been accepted.
Sourcefn get_entries(&self, from: u64, to: u64) -> StorageResult<Vec<T>>
fn get_entries(&self, from: u64, to: u64) -> StorageResult<Vec<T>>
Returns the entries in the log in the index interval of [from, to). If entries do not exist for the complete interval, an empty Vector should be returned.
Sourcefn get_log_len(&self) -> StorageResult<u64>
fn get_log_len(&self) -> StorageResult<u64>
Returns the current length of the log.
Sourcefn get_suffix(&self, from: u64) -> StorageResult<Vec<T>>
fn get_suffix(&self, from: u64) -> StorageResult<Vec<T>>
Returns the suffix of entries in the log from index from
.
Sourcefn get_promise(&self) -> StorageResult<Option<Ballot>>
fn get_promise(&self) -> StorageResult<Option<Ballot>>
Returns the round that has been promised.
Sourcefn set_stopsign(&mut self, s: Option<StopSign>) -> StorageResult<()>
fn set_stopsign(&mut self, s: Option<StopSign>) -> StorageResult<()>
Sets the StopSign used for reconfiguration.
Sourcefn get_stopsign(&self) -> StorageResult<Option<StopSign>>
fn get_stopsign(&self) -> StorageResult<Option<StopSign>>
Returns the stored StopSign, returns None
if no StopSign has been stored.
Sourcefn trim(&mut self, idx: u64) -> StorageResult<()>
fn trim(&mut self, idx: u64) -> StorageResult<()>
Removes elements up to the given [idx
] from storage.
Sourcefn set_compacted_idx(&mut self, idx: u64) -> StorageResult<()>
fn set_compacted_idx(&mut self, idx: u64) -> StorageResult<()>
Sets the compacted (i.e. trimmed or snapshotted) index.
Sourcefn get_compacted_idx(&self) -> StorageResult<u64>
fn get_compacted_idx(&self) -> StorageResult<u64>
Returns the garbage collector index from storage.
Sourcefn set_snapshot(&mut self, snapshot: Option<T::Snapshot>) -> StorageResult<()>
fn set_snapshot(&mut self, snapshot: Option<T::Snapshot>) -> StorageResult<()>
Sets the snapshot.
Sourcefn get_snapshot(&self) -> StorageResult<Option<T::Snapshot>>
fn get_snapshot(&self) -> StorageResult<Option<T::Snapshot>>
Returns the stored snapshot.