Struct talos_suffix::Suffix
source · pub struct Suffix<T> {
pub meta: SuffixMeta,
pub messages: VecDeque<Option<SuffixItem<T>>>,
}
Fields§
§meta: SuffixMeta
§messages: VecDeque<Option<SuffixItem<T>>>
Implementations§
source§impl<T> Suffix<T>
impl<T> Suffix<T>
sourcepub fn with_config(config: SuffixConfig) -> Suffix<T>
pub fn with_config(config: SuffixConfig) -> Suffix<T>
Creates a new suffix using the config passed.
The config can be used to control
- Required:
capacity
- The initial capacity of the suffix.
- Optional:
prune_start_threshold
- The threshold index beyond which pruning starts.- If
None
, no pruning will occur. - If
Some()
, attempts to prune suffix if suffix length crosses the threshold.
- If
pub fn index_from_head(&self, version: u64) -> Option<usize>
pub fn suffix_length(&self) -> usize
pub fn update_prune_index(&mut self, index: Option<usize>)
sourcepub fn reserve_space_if_required(
&mut self,
version: u64
) -> Result<(), SuffixError>
pub fn reserve_space_if_required( &mut self, version: u64 ) -> Result<(), SuffixError>
Reserve space when the version we are inserting is outside the upper bounds of suffix.
Reserves space and defaults them with None.
sourcepub fn are_prior_items_decided(&mut self, version: u64) -> bool
pub fn are_prior_items_decided(&mut self, version: u64) -> bool
Find prior versions are all decided.
Returns true, if the versions prior to the current version has either been decided or if suffix item is empty (None).
pub fn retrieve_all_some_vec_items(&self) -> Vec<(usize, u64, Option<u64>)>
pub fn find_prune_till_index(&self, prune_till_index: usize) -> usize
pub fn get_safe_prune_index(&self) -> Option<usize>
pub fn update_decision_suffix_item( &mut self, version: u64, decision_ver: u64 ) -> SuffixResult<()>
Trait Implementations§
source§impl<T> SuffixTrait<T> for Suffix<T>
impl<T> SuffixTrait<T> for Suffix<T>
source§fn prune_till_index(
&mut self,
index: usize
) -> SuffixResult<Vec<Option<SuffixItem<T>>>>
fn prune_till_index( &mut self, index: usize ) -> SuffixResult<Vec<Option<SuffixItem<T>>>>
Prune the suffix
Looks at the meta to find the prune ready version.
Prune is allowed when 1. The meta has a valid prune version. 2. And there is atleast one suffix item remaining, which can be the new head. This enables to move the head to the appropiate location.
fn get(&self, version: u64) -> SuffixResult<Option<SuffixItem<T>>>
fn get_mut(&mut self, version: u64) -> Option<&mut SuffixItem<T>>
fn get_meta(&self) -> &SuffixMeta
fn insert(&mut self, version: u64, message: T) -> SuffixResult<()>
fn update_decision( &mut self, version: u64, decision_ver: u64 ) -> SuffixResult<()>
fn prune_till_version( &mut self, version: u64 ) -> SuffixResult<Vec<Option<SuffixItem<T>>>>
fn remove(&mut self, version: u64) -> SuffixResult<()>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Suffix<T>where
T: RefUnwindSafe,
impl<T> Send for Suffix<T>where
T: Send,
impl<T> Sync for Suffix<T>where
T: Sync,
impl<T> Unpin for Suffix<T>where
T: Unpin,
impl<T> UnwindSafe for Suffix<T>where
T: UnwindSafe,
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