pub struct Resource<B>(/* private fields */)
where
B: 'static + ToOwned + ?Sized;
Expand description
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§
Source§impl<B> Resource<B>
impl<B> Resource<B>
Sourcepub fn changed(&self) -> bool
pub fn changed(&self) -> bool
Returns true
if the resource has changed since loading.
In release mode, always returns false
.
Sourcepub fn reload_if_changed(&mut self) -> bool
pub fn reload_if_changed(&mut self) -> bool
Reloads the resource only if it has changed since the previous
load. Returns true
if the resource was reloaded.
In release mode, does nothing.