Struct veloren_common_assets::Ron
#[repr(transparent)]pub struct Ron<T>(pub T);
Expand description
Loads a value from a JSON file.
This type can directly be used as an Asset
to load values
from an AssetCache
. This is useful to load assets external
types without a newtype wrapper (eg Vec
).
Tuple Fields§
§0: T
Implementations§
§impl<T> Ron<T>
impl<T> Ron<T>
pub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwraps the inner value.
Trait Implementations§
§impl<T> Asset for Ron<T>
impl<T> Asset for Ron<T>
§const EXTENSIONS: &'static [&'static str] = _
const EXTENSIONS: &'static [&'static str] = _
This field enables you to specify multiple extension for an asset. Read more
§fn default_value(
id: &SharedString,
error: Box<dyn Error + Send + Sync>,
) -> Result<Self, Box<dyn Error + Send + Sync>>
fn default_value( id: &SharedString, error: Box<dyn Error + Send + Sync>, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Specifies a eventual default value to use if an asset fails to load. If
this method returns
Ok
, the returned value is used as an asset. In
particular, if this method always returns Ok
, AssetCache::load
is
guaranteed not to fail. Read more§const HOT_RELOADED: bool = true
const HOT_RELOADED: bool = true
If
false
, disable hot-reloading for assets of this type (true
by
default). This avoids having to lock the asset to read it (ie it makes
[Handle::read
] a noop)source§impl<T: Concatenate> Concatenate for Ron<T>
impl<T: Concatenate> Concatenate for Ron<T>
fn concatenate(self, _b: Self) -> Self
§impl<'de, T> Deserialize<'de> for Ron<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Ron<T>where
T: Deserialize<'de>,
§fn deserialize<D>(
deserializer: D,
) -> Result<Ron<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Ron<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl<T> Ord for Ron<T>where
T: Ord,
impl<T> Ord for Ron<T>where
T: Ord,
§impl<T> PartialOrd for Ron<T>where
T: PartialOrd,
impl<T> PartialOrd for Ron<T>where
T: PartialOrd,
§fn partial_cmp(&self, other: &Ron<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Ron<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more§impl<T> Serialize for Ron<T>where
T: Serialize,
impl<T> Serialize for Ron<T>where
T: Serialize,
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T> Copy for Ron<T>where
T: Copy,
impl<T> Eq for Ron<T>where
T: Eq,
impl<T> StructuralPartialEq for Ron<T>
Auto Trait Implementations§
impl<T> Freeze for Ron<T>where
T: Freeze,
impl<T> RefUnwindSafe for Ron<T>where
T: RefUnwindSafe,
impl<T> Send for Ron<T>where
T: Send,
impl<T> Sync for Ron<T>where
T: Sync,
impl<T> Unpin for Ron<T>where
T: Unpin,
impl<T> UnwindSafe for Ron<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> AssetCombined for Twhere
T: Compound + Concatenate,
impl<T> AssetCombined for Twhere
T: Compound + Concatenate,
fn load_and_combine( reloading_cache: AnyCache<'static>, specifier: &str, ) -> Result<&'static Handle<T>, Error>
source§fn load_and_combine_static(specifier: &str) -> Result<AssetHandle<Self>, Error>
fn load_and_combine_static(specifier: &str) -> Result<AssetHandle<Self>, Error>
Load combined table without hot-reload support
fn load_expect_combined( reloading_cache: AnyCache<'static>, specifier: &str, ) -> AssetHandle<Self>
source§fn load_expect_combined_static(specifier: &str) -> AssetHandle<Self>
fn load_expect_combined_static(specifier: &str) -> AssetHandle<Self>
Load combined table without hot-reload support, panic on error
source§impl<T> AssetExt for Twhere
T: Compound,
impl<T> AssetExt for Twhere
T: Compound,
source§fn load(specifier: &str) -> Result<&'static Handle<T>, Error>
fn load(specifier: &str) -> Result<&'static Handle<T>, Error>
Function used to load assets from the filesystem or the cache.
Example usage: Read more
fn load_owned(specifier: &str) -> Result<T, Error>
fn get_or_insert(specifier: &str, default: T) -> &'static Handle<T>
source§fn load_cloned(specifier: &str) -> Result<Self, Error>where
Self: Clone,
fn load_cloned(specifier: &str) -> Result<Self, Error>where
Self: Clone,
Function used to load assets from the filesystem or the cache and return
a clone.
fn load_or_insert_with( specifier: &str, default: impl FnOnce(Error) -> Self, ) -> AssetHandle<Self>
source§fn load_expect(specifier: &str) -> AssetHandle<Self>
fn load_expect(specifier: &str) -> AssetHandle<Self>
Function used to load essential assets from the filesystem or the cache.
It will panic if the asset is not found. Example usage: Read more
source§fn load_expect_cloned(specifier: &str) -> Selfwhere
Self: Clone,
fn load_expect_cloned(specifier: &str) -> Selfwhere
Self: Clone,
Function used to load essential assets from the filesystem or the cache
and return a clone. It will panic if the asset is not found.
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Compound for Twhere
T: Asset,
impl<T> Compound for Twhere
T: Asset,
§fn load(
cache: AnyCache<'_>,
id: &SharedString,
) -> Result<T, Box<dyn Error + Send + Sync>>
fn load( cache: AnyCache<'_>, id: &SharedString, ) -> Result<T, Box<dyn Error + Send + Sync>>
Loads an asset from the cache. Read more
§const HOT_RELOADED: bool = Self::HOT_RELOADED
const HOT_RELOADED: bool = Self::HOT_RELOADED
If
false
, disable hot-reloading for assets of this type (true
by
default). This avoids having to lock the asset to read it (ie it makes
[Handle::read
] a noop)§impl<T> DirLoadable for Twhere
T: Asset,
impl<T> DirLoadable for Twhere
T: Asset,
§fn select_ids(
cache: AnyCache<'_>,
id: &SharedString,
) -> Result<Vec<SharedString>, Error>
fn select_ids( cache: AnyCache<'_>, id: &SharedString, ) -> Result<Vec<SharedString>, Error>
Returns the ids of the assets contained in the directory given by
id
. Read more§fn sub_directories(
cache: AnyCache<'_>,
id: &SharedString,
f: impl FnMut(&str),
) -> Result<(), Error>
fn sub_directories( cache: AnyCache<'_>, id: &SharedString, f: impl FnMut(&str), ) -> Result<(), Error>
Executes the given closure for each id of a child directory of the given
directory. The default implementation reads the cache’s source.
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more