[−][src]Struct resource::Resource
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.
Methods
impl<B: ?Sized> Resource<B> where
B: 'static + ToOwned,
B::Owned: ReadFromFile,
[src]
B: 'static + ToOwned,
B::Owned: ReadFromFile,
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]
B: 'static + ToOwned,
B::Owned: AsRef<B>,
impl<B: ?Sized> Clone for Resource<B> where
B: 'static + ToOwned,
B::Owned: Clone,
[src]
B: 'static + ToOwned,
B::Owned: Clone,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<B: ?Sized> Deref for Resource<B> where
B: 'static + ToOwned,
B::Owned: AsRef<B>,
[src]
B: 'static + ToOwned,
B::Owned: AsRef<B>,
impl<B: ?Sized> Into<Cow<'static, B>> for Resource<B> where
B: 'static + ToOwned,
[src]
B: 'static + ToOwned,
Auto Trait Implementations
impl<B: ?Sized> RefUnwindSafe for Resource<B> where
<B as ToOwned>::Owned: RefUnwindSafe,
<B as ToOwned>::Owned: RefUnwindSafe,
impl<B: ?Sized> Send for Resource<B> where
<B as ToOwned>::Owned: Send,
<B as ToOwned>::Owned: Send,
impl<B: ?Sized> Sync for Resource<B> where
<B as ToOwned>::Owned: Sync,
<B as ToOwned>::Owned: Sync,
impl<B: ?Sized> Unpin for Resource<B> where
<B as ToOwned>::Owned: Unpin,
<B as ToOwned>::Owned: Unpin,
impl<B: ?Sized> UnwindSafe for Resource<B> where
<B as ToOwned>::Owned: UnwindSafe,
<B as ToOwned>::Owned: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,