Skip to main content

StringTable

Struct StringTable 

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

A table of deduplicated strings read from String records in the binlog stream.

Strings are appended in the order they appear (each String record gets the next sequential index starting at [STRING_START_INDEX]). Event payloads reference strings by index.

Implementations§

Source§

impl StringTable

Source

pub fn new() -> Self

Create an empty string table.

Source

pub fn add(&mut self, value: String) -> i32

Add a string record. Returns the index assigned to it.

Source

pub fn get(&self, index: i32) -> Result<Option<&str>, MuninError>

Look up a string by its on-disk index.

  • Index 0 → Ok(None) (null)
  • Index 1 → Ok(Some("")) (empty)
  • Index 2–9 → Err(InvalidIndex) (reserved, not yet assigned meaning)
  • Index ≥ 10 → lookup in the table
Source

pub fn len(&self) -> usize

Number of string records ingested so far.

Source

pub fn is_empty(&self) -> bool

Whether the table is empty (no string records ingested).

Source

pub fn entries(&self) -> &[String]

Borrow the stored strings in insertion (index) order.

Source

pub fn entries_mut(&mut self) -> &mut [String]

Mutably borrow the stored strings in insertion (index) order.

Provided for in-place rewrites that must preserve indices (e.g. crate::redact). Replacing an entry’s contents keeps every existing string-index reference valid, since indices are positional.

Trait Implementations§

Source§

impl Debug for StringTable

Source§

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

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

impl Default for StringTable

Source§

fn default() -> StringTable

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