Struct raft::storage::MemStorage [−][src]
MemStorage
is a thread-safe but incomplete implementation of Storage
, mainly for tests.
A real Storage
should save both raft logs and applied data. However MemStorage
only
contains raft logs. So you can call MemStorage::append
to persist new received unstable raft
logs and then access them with Storage
APIs. The only exception is Storage::snapshot
. There
is no data in Snapshot
returned by MemStorage::snapshot
because applied data is not stored
in MemStorage
.
Implementations
impl MemStorage
[src]
pub fn new() -> MemStorage
[src]
Returns a new memory storage value.
pub fn new_with_conf_state<T>(conf_state: T) -> MemStorage where
ConfState: From<T>,
[src]
ConfState: From<T>,
Create a new MemStorage
with a given Config
. The given Config
will be used to
initialize the storage.
You should use the same input to initialize all nodes.
pub fn initialize_with_conf_state<T>(&self, conf_state: T) where
ConfState: From<T>,
[src]
ConfState: From<T>,
Initialize a MemStorage
with a given Config
.
You should use the same input to initialize all nodes.
pub fn rl(&self) -> RwLockReadGuard<'_, MemStorageCore>
[src]
Opens up a read lock on the storage and returns a guard handle. Use this with functions that don’t require mutation.
pub fn wl(&self) -> RwLockWriteGuard<'_, MemStorageCore>
[src]
Opens up a write lock on the storage and returns guard handle. Use this with functions that take a mutable reference to self.
Trait Implementations
impl Clone for MemStorage
[src]
fn clone(&self) -> MemStorage
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Default for MemStorage
[src]
fn default() -> MemStorage
[src]
impl Storage for MemStorage
[src]
fn initial_state(&self) -> Result<RaftState>
[src]
Implements the Storage trait.
fn entries(
&self,
low: u64,
high: u64,
max_size: impl Into<Option<u64>>
) -> Result<Vec<Entry>>
[src]
&self,
low: u64,
high: u64,
max_size: impl Into<Option<u64>>
) -> Result<Vec<Entry>>
Implements the Storage trait.
fn term(&self, idx: u64) -> Result<u64>
[src]
Implements the Storage trait.
fn first_index(&self) -> Result<u64>
[src]
Implements the Storage trait.
fn last_index(&self) -> Result<u64>
[src]
Implements the Storage trait.
fn snapshot(&self, request_index: u64) -> Result<Snapshot>
[src]
Implements the Storage trait.
Auto Trait Implementations
impl RefUnwindSafe for MemStorage
impl Send for MemStorage
impl Sync for MemStorage
impl Unpin for MemStorage
impl UnwindSafe for MemStorage
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
[src]
T: Send + Sync + UnwindSafe + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,