Struct keeshond_datapack::DataHandle[][src]

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

A path to a data resource, resolvable to a cached DataId.

Implementations

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

pub fn new(package: &str, path: &str) -> DataHandle<T>[src]

Creates a new DataHandle with the given resource path. The data ID will be unresolved. You will need to call resolve() for the data ID to point to a valid resource.

pub fn set_path(&mut self, package: &str, path: &str)[src]

Changes the resource path. The data ID will reset to be unresolved. You will need to call resolve() for the data ID to point to a valid resource.

pub fn package(&self) -> &String[src]

Returns the package name part of the resource path

pub fn path(&self) -> &String[src]

Returns the filepath to the resource

pub fn id(&self) -> DataId[src]

Returns the data ID. You will need to call resolve() beforehand for the data ID to point to a valid resource.

pub fn resolved(&self) -> bool[src]

Returns true if the path has been resolved via a call to resolve().

pub fn resolve(
    &self,
    data_res: &mut DataStore<T>,
    load_error: LoadErrorMode
) -> DataId
[src]

Resolves the data ID using the given DataStore. Returns the resolved data ID, which is cached inside the object. If load_error is Fatal, this function will panic if the load fails. Otherwise it will simply return a null data ID.

pub fn get<'a, 'b: 'a>(
    &self,
    data_res: &'b mut DataStore<T>,
    load_error: LoadErrorMode
) -> Option<&'a T>
[src]

Returns a reference to data object in the store, if it exists. If the data object is not resolved, then resolve() will be called, and then the data object reference returned, if available.

pub fn get_mut<'a, 'b: 'a>(
    &self,
    data_res: &'b mut DataStore<T>,
    load_error: LoadErrorMode
) -> Option<&'a mut T>
[src]

Returns a mutable reference to data object in the store, if it exists. If the data object is not resolved, then resolve() will be called, and then the data object reference returned, if available.

pub fn get_if_resolved<'a, 'b: 'a>(
    &self,
    data_res: &'b DataStore<T>
) -> Option<&'a T>
[src]

Returns a reference to data object in the store, if it exists. If the data object is not resolved, returns None instead of attempting to resolve.

pub fn get_mut_if_resolved<'a, 'b: 'a>(
    &self,
    data_res: &'b mut DataStore<T>
) -> Option<&'a mut T>
[src]

Returns a mutable reference to data object in the store, if it exists. If the data object is not resolved, returns None instead of attempting to resolve.

pub fn resolve_if_loaded(&self, data_res: &DataStore<T>) -> DataId[src]

Resolves the data ID using the given DataStore. Returns the resolved data ID, which is cached inside the object. If the data is not yet loaded, returns a null ID.

Trait Implementations

impl<T: DataObject + 'static> Clone for DataHandle<T>[src]

fn clone(&self) -> Self[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T: DataObject + 'static> Debug for DataHandle<T>[src]

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

Formats the value using the given formatter. Read more

impl<T: DataObject + 'static> Default for DataHandle<T>[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

Auto Trait Implementations

impl<T> !RefUnwindSafe for DataHandle<T>

impl<T> Send for DataHandle<T> where
    T: Send

impl<T> !Sync for DataHandle<T>

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

impl<T> UnwindSafe for DataHandle<T> where
    T: UnwindSafe

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.