[][src]Struct keeshond_datapack::DataStore

pub struct DataStore<T: DataObject + 'static> { /* fields omitted */ }

Storage that allows lookup and access of DataObjects of a given type

Implementations

impl<T: DataObject + 'static> DataStore<T>[src]

pub fn new(source_manager: Rc<RefCell<SourceManager>>) -> DataStore<T>[src]

Constructs a new DataStore that gets its Sources from the given SourceManager

pub fn load_package(
    &mut self,
    package_name: &str
) -> Result<DataStoreOk, DataError>
[src]

Loads the package by the given name if it is not already loaded.

pub fn get_id(
    &self,
    package_name: &str,
    pathname: &str
) -> Result<DataId, DataError>
[src]

Gets the numeric ID of the DataObject from the given package at the given pathname.

pub fn get_id_mut(
    &mut self,
    package_name: &str,
    pathname: &str
) -> Result<DataId, DataError>
[src]

Gets the numeric ID of the DataObject from the given package at the given pathname. If the package is not loaded, it will be loaded automatically.

pub fn get(&self, index: DataId) -> Option<&T>[src]

Returns a reference to the DataObject by the given DataId, if one exists. Otherwise returns None.

pub fn get_mut(&mut self, index: DataId) -> Option<&mut T>[src]

Returns a mutable reference to the DataObject by the given DataId, if one exists. Otherwise returns None.

pub fn list_package_contents(&self, package_name: &str) -> Vec<String>[src]

Returns a string list of the names of each DataObject in the given package. The package will need to have been loaded or this will return an empty list. Please do not call this repeatedly.

pub fn unload_package(&mut self, package_name: &str) -> bool[src]

Unloads the given package from memory. Any DataObjects will be dropped, but pathname-id mappings will be retained in memory so that existing references will not be invalidated. Returns true if the package was loaded.

pub fn unload_all(&mut self)[src]

Unloads all packages from memory. Any DataObjects will be dropped, but pathname-id mappings will be retained in memory so that existing references will not be invalidated. Returns true if the package was loaded.

pub fn package_loaded(&self, package_name: &str) -> bool[src]

Returns true if the given package is loaded.

pub fn save(
    &mut self,
    package_name: &str,
    pathname: &str,
    source_id: SourceId
) -> Result<(), DataError>
[src]

Saves the indicated item using the Source given by SourceId.

pub fn reprepare(&mut self, index: DataId) -> bool[src]

Marks the DataObject by the given DataId as needing to be "reprepared". Use this, for example, when data has been changed and it needs to be reflected in a backend via the PreparedStore. Returns true if the data was marked for reprepare, otherwise false.

pub fn reload(
    &mut self,
    package_name: &str,
    pathname: &str
) -> Result<(), DataError>
[src]

Reloads an already-loaded resource by the given name.

Auto Trait Implementations

impl<T> !RefUnwindSafe for DataStore<T>

impl<T> !Send for DataStore<T>

impl<T> !Sync for DataStore<T>

impl<T> Unpin for DataStore<T> where
    T: Unpin

impl<T> !UnwindSafe for DataStore<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.