[][src]Trait folia::store::Store

pub trait Store<T, Key> where
    T: Storable<Key>,
    Key: TryFrom<usize> + Copy + Debug,
    usize: TryFrom<Key>,
    <usize as TryFrom<Key>>::Error: Debug
{ fn items_mut(&mut self) -> &mut Vec<Option<Box<T>>>;
fn index_mut(&mut self) -> &mut HashMap<String, Key>;
fn items(&self) -> &Vec<Option<Box<T>>>;
fn iter(&self) -> Iter<'_, Option<Box<T>>>;
fn index(&self) -> &HashMap<String, Key>; fn encode(
        &mut self,
        item: T,
        _context: Option<Key>
    ) -> Result<T, FoliaError> { ... }
fn add(&mut self, item: T, context: Option<Key>) -> Result<Key, FoliaError> { ... }
fn get_key(&self, item: &T) -> Option<Key> { ... }
fn is_empty(&self) -> bool { ... }
fn len(&self) -> usize { ... }
fn get(&self, key: Key) -> Option<&T> { ... }
fn get_mut(&mut self, key: Key) -> Option<&mut T> { ... }
fn id_to_key(&self, id: &str) -> Option<Key> { ... }
fn get_by_id(&self, id: &str) -> Option<&T> { ... }
fn get_mut_by_id(&mut self, id: &str) -> Option<&mut T> { ... } }

Holds and owns all items, the index to them and their declarations. The store serves as an abstraction used by Documents

Required methods

fn items_mut(&mut self) -> &mut Vec<Option<Box<T>>>

fn index_mut(&mut self) -> &mut HashMap<String, Key>

fn items(&self) -> &Vec<Option<Box<T>>>

fn iter(&self) -> Iter<'_, Option<Box<T>>>

fn index(&self) -> &HashMap<String, Key>

Loading content...

Provided methods

fn encode(&mut self, item: T, _context: Option<Key>) -> Result<T, FoliaError>

fn add(&mut self, item: T, context: Option<Key>) -> Result<Key, FoliaError>

Add a new item to the store (takes ownership)

fn get_key(&self, item: &T) -> Option<Key>

Checks if an item is already in the store and returns the key if so, only works for identifiable items (so it's guaranteed O(1))

fn is_empty(&self) -> bool

fn len(&self) -> usize

Returns the number of items in the store (including items that were removed)

fn get(&self, key: Key) -> Option<&T>

Retrieves an element from the store

fn get_mut(&mut self, key: Key) -> Option<&mut T>

Retrieves an element from the store

fn id_to_key(&self, id: &str) -> Option<Key>

Resolve an ID to a Key using the index

fn get_by_id(&self, id: &str) -> Option<&T>

Get by key, where key is still a string to be resolved. Shortcut function calling key() and get()

fn get_mut_by_id(&mut self, id: &str) -> Option<&mut T>

Get (mutably) by key, where key is still a string to be resolved. Shortcut function calling key() and get_mut()

Loading content...

Implementors

impl Store<ElementData, u32> for Document[src]

fn encode(
    &mut self,
    element: ElementData,
    context: Option<ElementKey>
) -> Result<ElementData, FoliaError>
[src]

Actively encode element for storage, this encodes attributes that need to be encoded (such as set,class,processor), and adds them to their respective stores. It does not handle relations between elements (data/children and parent) nor does it add the element itself to the store to the store).

impl Store<Declaration, u16> for Document[src]

impl Store<Processor, u16> for Document[src]

Loading content...