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>
where T: Sized + Clone + Debug,

source

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.
source

pub fn index_from_head(&self, version: u64) -> Option<usize>

source

pub fn suffix_length(&self) -> usize

source

pub fn update_prune_index(&mut self, index: Option<usize>)

source

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.

source

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).

source

pub fn retrieve_all_some_vec_items(&self) -> Vec<(usize, u64, Option<u64>)>

source

pub fn find_prune_till_index(&self, prune_till_index: usize) -> usize

source

pub fn get_safe_prune_index(&self) -> Option<usize>

source

pub fn update_decision_suffix_item( &mut self, version: u64, decision_ver: u64 ) -> SuffixResult<()>

Trait Implementations§

source§

impl<T: Clone> Clone for Suffix<T>

source§

fn clone(&self) -> Suffix<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Suffix<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> SuffixTrait<T> for Suffix<T>
where T: Sized + Clone + Debug,

source§

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.

source§

fn get(&self, version: u64) -> SuffixResult<Option<SuffixItem<T>>>

source§

fn get_mut(&mut self, version: u64) -> Option<&mut SuffixItem<T>>

source§

fn get_meta(&self) -> &SuffixMeta

source§

fn insert(&mut self, version: u64, message: T) -> SuffixResult<()>

source§

fn update_decision( &mut self, version: u64, decision_ver: u64 ) -> SuffixResult<()>

source§

fn prune_till_version( &mut self, version: u64 ) -> SuffixResult<Vec<Option<SuffixItem<T>>>>

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.