Skip to main content

ItemInterner

Struct ItemInterner 

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

Per-category name -> ItemId interner used while importing rows: dimension values are looked up (reusing an existing item of that name) or minted a fresh sequential id. Seed from the model’s current items so re-import / refresh reuses items instead of creating duplicates with the same name.

Implementations§

Source§

impl ItemInterner

Source

pub fn seeded_from(model: &Model, item_id_base: u32) -> Self

Seed the interner from model’s existing items. Minted ids start at item_id_base, but never below max(existing item id) + 1: on a repeat import the caller passes the same fixed base (the GUI wizard always passes 1_000_000), so allocating straight from the base would re-mint an id a differently named item already owns — register then keeps the old name and the new row’s value silently lands under the wrong label. Allocating above the model’s maximum guarantees freshness while the base still acts as the floor for a fresh import.

Source

pub fn intern(&mut self, category: CategoryId, name: &str) -> ItemId

Look up (or mint) the item id for name under category.

Source

pub fn register(&self, model: &mut Model)

Register every interned item into model’s items/categories maps. Call once, after all rows are interned.

Trait Implementations§

Source§

impl Debug for ItemInterner

Source§

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

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

impl Default for ItemInterner

Source§

fn default() -> ItemInterner

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.