pub struct Log { /* private fields */ }Expand description
In-memory representation of a Node local log.
Implementations§
source§impl Log
impl Log
sourcepub const fn new(snapshot_config: ClusterConfig, entries: LogEntries) -> Self
pub const fn new(snapshot_config: ClusterConfig, entries: LogEntries) -> Self
Makes a new Log instance with the given cluster configuration and entries.
§Examples
use raftbare::{ClusterConfig, Log, LogEntries, LogEntry, LogPosition, NodeId, Term};
let empty_config = ClusterConfig::new();
let mut single_config = ClusterConfig::new();
single_config.voters.insert(NodeId::new(1));
let entries = LogEntries::from_iter(
LogPosition::ZERO,
vec![
LogEntry::Term(Term::ZERO),
LogEntry::ClusterConfig(single_config.clone()),
LogEntry::Command,
],
);
let log = Log::new(empty_config.clone(), entries);
assert_eq!(log.snapshot_position(), LogPosition::ZERO);
assert_eq!(log.snapshot_config(), &empty_config);
assert_eq!(log.latest_config(), &single_config);sourcepub fn entries(&self) -> &LogEntries
pub fn entries(&self) -> &LogEntries
Returns a reference to the entries in this log.
sourcepub fn last_position(&self) -> LogPosition
pub fn last_position(&self) -> LogPosition
Returns the position of the last entry in this log.
This is equivalent to self.entries().last_position().
sourcepub fn snapshot_position(&self) -> LogPosition
pub fn snapshot_position(&self) -> LogPosition
Returns the log position where the snapshot was taken.
This is equivalent to self.entries().prev_position().
sourcepub fn snapshot_config(&self) -> &ClusterConfig
pub fn snapshot_config(&self) -> &ClusterConfig
Returns a reference to the cluster configuration at the time the snapshot was taken.
sourcepub fn latest_config(&self) -> &ClusterConfig
pub fn latest_config(&self) -> &ClusterConfig
Returns a reference to the cluster configuration located at the highest index in this log.
Trait Implementations§
impl Eq for Log
impl StructuralPartialEq for Log
Auto Trait Implementations§
impl Freeze for Log
impl RefUnwindSafe for Log
impl Send for Log
impl Sync for Log
impl Unpin for Log
impl UnwindSafe for Log
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)