Skip to main content

SymbolSet

Struct SymbolSet 

Source
pub struct SymbolSet { /* private fields */ }
Expand description

A collection of symbols with threshold tracking.

Implementations§

Source§

impl SymbolSet

Source

pub fn new() -> Self

Creates a new SymbolSet with the default threshold configuration.

Source

pub fn with_config(config: ThresholdConfig) -> Self

Creates a new SymbolSet with the specified configuration.

Source

pub fn with_memory_budget(config: ThresholdConfig, budget_bytes: usize) -> Self

Creates a new SymbolSet with a memory budget.

Source

pub fn insert(&mut self, symbol: Symbol) -> InsertResult

Inserts a symbol into the set.

Source

pub fn insert_batch( &mut self, symbols: impl Iterator<Item = Symbol>, ) -> Vec<InsertResult>

Inserts multiple symbols into the set.

Source

pub fn set_block_k(&mut self, sbn: u8, k: u16) -> bool

Sets the source-symbol count (K) for a block.

Returns true if the threshold is now reached for that block.

Source

pub fn contains(&self, id: &SymbolId) -> bool

Returns true if a symbol is present.

Source

pub fn get(&self, id: &SymbolId) -> Option<&Symbol>

Gets a symbol by ID.

Source

pub fn remove(&mut self, id: &SymbolId) -> Option<Symbol>

Removes a symbol by ID.

Source

pub fn symbols_for_block(&self, sbn: u8) -> impl Iterator<Item = &Symbol>

Returns an iterator over all symbols for a block.

Source

pub fn block_progress(&self, sbn: u8) -> Option<&BlockProgress>

Returns block progress for a given block.

Source

pub fn threshold_reached(&self, sbn: u8) -> bool

Returns true if the threshold is reached for a block.

Source

pub fn ready_blocks(&self) -> Vec<u8>

Returns all blocks that have reached the threshold.

Source

pub const fn len(&self) -> usize

Returns the total number of symbols stored.

Source

pub const fn is_empty(&self) -> bool

Returns true if no symbols are stored.

Source

pub const fn memory_usage(&self) -> usize

Returns estimated memory usage in bytes.

Source

pub fn clear(&mut self)

Clears all symbols.

Source

pub fn iter(&self) -> impl Iterator<Item = (&SymbolId, &Symbol)>

Iterates over all symbols in the set.

Source

pub fn drain(&mut self) -> impl Iterator<Item = (SymbolId, Symbol)>

Drains all symbols from the set.

Source

pub fn clear_block(&mut self, sbn: u8)

Clears symbols for a specific block.

Trait Implementations§

Source§

impl Debug for SymbolSet

Source§

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

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

impl Default for SymbolSet

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more