pub struct SymbolTable { /* private fields */ }
Expand description

A symbol table section in a KerbalObject file.

This section stores a list of all symbols that this object file stores and references.

Implementations§

source§

impl SymbolTable

source

pub fn new(section_index: SectionIdx) -> Self

Creates a new symbol table section with the provided section index

source

pub fn with_capacity(amount: usize, section_index: SectionIdx) -> Self

Creates a new symbol table section with the provided section index, with internal data structures pre-allocated for the provided amount of symbols

source

pub fn get(&self, index: SymbolIdx) -> Option<&KOSymbol>

Gets the symbol at the provided index into this symbol table, or None if it doesn’t exist.

source

pub fn find_by_name(&self, name_idx: StringIdx) -> Option<&KOSymbol>

Returns the KOSymbol by the provided name index (from the .symstrtab), or None if it doesn’t exist

source

pub fn position_by_name(&self, name_idx: StringIdx) -> Option<SymbolIdx>

Returns the position/index in this symbol table of the symbol of the provided name index (from the .symstrtab), or None if it doesn’t exist

source

pub fn find(&self, symbol: &KOSymbol) -> Option<SymbolIdx>

Returns the position/index in this symbol table of the provided symbol, or None if it doesn’t exist

source

pub fn add(&mut self, symbol: KOSymbol) -> SymbolIdx

Adds a new symbol to this symbol table, returning the index of the symbol into this section. Doesn’t do anything like checking if a symbol with that name already exists in the table

source

pub fn add_checked(&mut self, symbol: KOSymbol) -> SymbolIdx

Adds a new symbol to this symbol table, returning the index of the symbol into this section. Checks if a symbol with the same name is already in the table, and in that case just returns the index of that symbol

source

pub fn size(&self) -> u32

The size of this symbol table section in bytes

source

pub fn symbols(&self) -> Iter<'_, KOSymbol>

Returns an iterator over all symbols in this symbol table

source

pub fn section_index(&self) -> SectionIdx

The index of this section’s section header

source

pub fn parse( source: &mut BufferIterator<'_>, size: u32, section_index: SectionIdx ) -> Result<Self, SymbolTableParseError>

Parses a symbol table from the provided byte buffer

source

pub fn write(&self, buf: &mut impl WritableBuffer)

Converts this symbol table to its binary representation and appends it to the provided buffer

Trait Implementations§

source§

impl Debug for SymbolTable

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.