Struct ion_rs::SymbolTable
source · [−]pub struct SymbolTable { /* private fields */ }
Expand description
Stores mappings from Symbol IDs to text and vice-versa.
Implementations
sourceimpl SymbolTable
impl SymbolTable
sourcepub fn new() -> SymbolTable
pub fn new() -> SymbolTable
Constructs a new symbol table pre-populated with the system symbols defined in the spec.
pub fn reset(&mut self)
sourcepub fn add_placeholder(&mut self) -> SymbolId
pub fn add_placeholder(&mut self) -> SymbolId
Assigns unknown text to the next available symbol ID. This is used when an Ion reader encounters null or non-string values in a stream’s symbol table.
sourcepub fn intern_or_add_placeholder<A: AsRef<str>>(
&mut self,
maybe_text: Option<A>
) -> SymbolId
pub fn intern_or_add_placeholder<A: AsRef<str>>(
&mut self,
maybe_text: Option<A>
) -> SymbolId
If maybe_text
is Some(text)
, this method is equivalent to intern(text)
.
If maybe_text
is None
, this method is equivalent to add_placeholder()
.
sourcepub fn sid_for<A: AsRef<str>>(&self, text: &A) -> Option<SymbolId>
pub fn sid_for<A: AsRef<str>>(&self, text: &A) -> Option<SymbolId>
If defined, returns the Symbol ID associated with the provided text.
sourcepub fn text_for(&self, sid: SymbolId) -> Option<&str>
pub fn text_for(&self, sid: SymbolId) -> Option<&str>
If defined, returns the text associated with the provided Symbol ID.
sourcepub fn symbol_for(&self, sid: SymbolId) -> Option<&Symbol>
pub fn symbol_for(&self, sid: SymbolId) -> Option<&Symbol>
If defined, returns the Symbol associated with the provided Symbol ID.
sourcepub fn sid_is_valid(&self, sid: SymbolId) -> bool
pub fn sid_is_valid(&self, sid: SymbolId) -> bool
Returns true if the provided symbol ID maps to an entry in the symbol table (i.e. it is in the range of known symbols: 0 to max_id)
Note that a symbol ID can be valid but map to unknown text. If a symbol table contains a null or non-string value, that entry in the table will be defined but not have text associated with it.
This method allows users to distinguish between a SID with unknown text and a SID that is invalid.
sourcepub fn symbols(&self) -> &[Option<Symbol>]
pub fn symbols(&self) -> &[Option<Symbol>]
Returns a slice of references to the symbol text stored in the table.
The symbol table can contain symbols with unknown text; if the text for a given symbol is unknown, the corresponding entry in the slice will be None.
sourcepub fn symbols_tail(&self, start: usize) -> &[Option<Symbol>]
pub fn symbols_tail(&self, start: usize) -> &[Option<Symbol>]
Returns a slice of references to the symbol text stored in the table starting at the given symbol ID. If a symbol table append occurs during reading, this function can be used to easily view the new symbols that has been added to the table.
The symbol table can contain symbols with unknown text; if the text for a given symbol is unknown, the corresponding entry in the slice will be None.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for SymbolTable
impl !Send for SymbolTable
impl !Sync for SymbolTable
impl Unpin for SymbolTable
impl UnwindSafe for SymbolTable
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more