pub struct SharedStringTable { /* private fields */ }Expand description
Runtime shared string table for efficient string lookup and insertion.
Maintains both an ordered list of strings (for index-based lookup) and a
reverse hash map (for deduplication when inserting). Original Si items
loaded from file are preserved so that to_sst() can reuse them without
cloning the string data a second time.
Implementations§
Sourcepub fn from_sst(sst: Sst) -> Self
pub fn from_sst(sst: Sst) -> Self
Build from an XML Sst, taking ownership to avoid cloning items.
Plain-text items use the t field directly. Rich-text items
concatenate all run texts. Pre-sizes internal containers.
Sourcepub fn add(&mut self, s: &str) -> usize
pub fn add(&mut self, s: &str) -> usize
Add a string by reference, returning its index.
If the string already exists, the existing index is returned (dedup).
Sourcepub fn add_owned(&mut self, s: String) -> usize
pub fn add_owned(&mut self, s: String) -> usize
Add a string by value, returning its index.
Avoids one allocation compared to add() when the caller already
owns a String.
Sourcepub fn add_rich_text(&mut self, runs: &[RichTextRun]) -> usize
pub fn add_rich_text(&mut self, runs: &[RichTextRun]) -> usize
Add rich text runs, returning the SST index.
The plain-text concatenation of the runs is used for deduplication.
Sourcepub fn get_rich_text(&self, index: usize) -> Option<Vec<RichTextRun>>
pub fn get_rich_text(&self, index: usize) -> Option<Vec<RichTextRun>>
Get rich text runs for an SST entry, if it has formatting.
Returns None for plain-text entries.