[][src]Struct resource::Resource

pub struct Resource<B: ?Sized>(_, _, _)
where
    B: 'static + ToOwned
;

A resource (string or binary) loaded in memory.

In debug mode, this structure contains the data, the path to the file, and a timestamp in order to support the reload_if_changed method.

In release mode, it contains only an immutable, static reference to the data.

This struct implements Deref and AsRef (for the &str and &[u8] types respectively) which allows you to refer transparently to the data.

Alternatively, it also implements Into<Cow<'static, T>>. In debug mode, this will return a Cow that owns the data. In release mode, it returns a Cow that borrows the static data.

Implementations

impl<B: ?Sized> Resource<B> where
    B: 'static + ToOwned,
    B::Owned: ReadFromFile
[src]

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

Returns true if the resource has changed since loading.

In release mode, always returns false.

pub fn reload(&mut self)[src]

Reloads the resource.

In release mode, does nothing.

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

Reloads the resource only if it has changed since the previous load. Returns true if the resource was reloaded.

In release mode, does nothing.

Trait Implementations

impl<B: ?Sized> AsRef<B> for Resource<B> where
    B: 'static + ToOwned,
    B::Owned: AsRef<B>, 
[src]

impl<B: ?Sized> Clone for Resource<B> where
    B: 'static + ToOwned,
    B::Owned: Clone
[src]

impl<B: ?Sized> Deref for Resource<B> where
    B: 'static + ToOwned,
    B::Owned: AsRef<B>, 
[src]

type Target = B

The resulting type after dereferencing.

impl<B: ?Sized> Into<Cow<'static, B>> for Resource<B> where
    B: 'static + ToOwned
[src]

Auto Trait Implementations

impl<B: ?Sized> RefUnwindSafe for Resource<B> where
    <B as ToOwned>::Owned: RefUnwindSafe

impl<B: ?Sized> Send for Resource<B> where
    <B as ToOwned>::Owned: Send

impl<B: ?Sized> Sync for Resource<B> where
    <B as ToOwned>::Owned: Sync

impl<B: ?Sized> Unpin for Resource<B> where
    <B as ToOwned>::Owned: Unpin

impl<B: ?Sized> UnwindSafe for Resource<B> where
    <B as ToOwned>::Owned: UnwindSafe

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.