Enum bevy::asset::AssetId

pub enum AssetId<A>where
    A: Asset,{
    Index {
        index: AssetIndex,
        marker: PhantomData<fn() -> A>,
    },
    Uuid {
        uuid: Uuid,
    },
}
Expand description

A unique runtime-only identifier for an Asset. This is cheap to Copy/Clone and is not directly tied to the lifetime of the Asset. This means it can point to an Asset that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an “untyped” / “generic-less” id, see UntypedAssetId.

Variants§

§

Index

Fields

§marker: PhantomData<fn() -> A>

A small / efficient runtime identifier that can be used to efficiently look up an asset stored in Assets. This is the “default” identifier used for assets. The alternative(s) (ex: AssetId::Uuid) will only be used if assets are explicitly registered that way.

§

Uuid

Fields

§uuid: Uuid

A stable-across-runs / const asset identifier. This will only be used if an asset is explicitly registered in Assets with one.

Implementations§

§

impl<A> AssetId<A>where A: Asset,

pub const DEFAULT_UUID: Uuid = _

The uuid for the default AssetId. It is valid to assign a value to this in Assets and by convention (where appropriate) assets should support this pattern.

pub const INVALID_UUID: Uuid = _

This asset id should never be valid. Assigning a value to this in Assets will produce undefined behavior, so don’t do it!

pub const fn invalid() -> AssetId<A>

Returns an AssetId with Self::INVALID_UUID, which should never be assigned to.

pub fn untyped(self) -> UntypedAssetId

Converts this to an “untyped” / “generic-less” Asset identifier that stores the type information inside the UntypedAssetId.

Trait Implementations§

§

impl<A> Clone for AssetId<A>where A: Asset,

§

fn clone(&self) -> AssetId<A>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<A> Debug for AssetId<A>where A: Asset,

§

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

Formats the value using the given formatter. Read more
§

impl<A> Default for AssetId<A>where A: Asset,

§

fn default() -> AssetId<A>

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

impl<A> Display for AssetId<A>where A: Asset,

§

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

Formats the value using the given formatter. Read more
§

impl<A> Enum for AssetId<A>where A: Asset + TypePath, AssetIndex: FromReflect + TypePath, Uuid: FromReflect + TypePath, PhantomData<fn() -> A>: Any + Send + Sync,

§

fn field(&self, __name_param: &str) -> Option<&(dyn Reflect + 'static)>

Returns a reference to the value of the field (in the current variant) with the given name. Read more
§

fn field_at(&self, __index_param: usize) -> Option<&(dyn Reflect + 'static)>

Returns a reference to the value of the field (in the current variant) at the given index.
§

fn field_mut( &mut self, __name_param: &str ) -> Option<&mut (dyn Reflect + 'static)>

Returns a mutable reference to the value of the field (in the current variant) with the given name. Read more
§

fn field_at_mut( &mut self, __index_param: usize ) -> Option<&mut (dyn Reflect + 'static)>

Returns a mutable reference to the value of the field (in the current variant) at the given index.
§

fn index_of(&self, __name_param: &str) -> Option<usize>

Returns the index of the field (in the current variant) with the given name. Read more
§

fn name_at(&self, __index_param: usize) -> Option<&str>

Returns the name of the field (in the current variant) with the given index. Read more
§

fn iter_fields(&self) -> VariantFieldIter<'_>

Returns an iterator over the values of the current variant’s fields.
§

fn field_len(&self) -> usize

Returns the number of fields in the current variant.
§

fn variant_name(&self) -> &str

The name of the current variant.
§

fn variant_index(&self) -> usize

The index of the current variant.
§

fn variant_type(&self) -> VariantType

The type of the current variant.
§

fn clone_dynamic(&self) -> DynamicEnum

§

fn is_variant(&self, variant_type: VariantType) -> bool

Returns true if the current variant’s type matches the given one.
§

fn variant_path(&self) -> String

Returns the full path to the current variant.
§

impl<A> ExtractInstance for AssetId<A>where A: Asset,

§

type Query = &'static Handle<A>

ECS WorldQuery to fetch the components to extract.
§

type Filter = ()

Filters the entities with additional constraints.
§

fn extract( item: <<AssetId<A> as ExtractInstance>::Query as WorldQuery>::Item<'_> ) -> Option<AssetId<A>>

Defines how the component is transferred into the “render world”.
§

impl<A> From<&Handle<A>> for AssetId<A>where A: Asset,

§

fn from(value: &Handle<A>) -> AssetId<A>

Converts to this type from the input type.
§

impl<A> From<&UntypedAssetId> for AssetId<A>where A: Asset,

§

fn from(value: &UntypedAssetId) -> AssetId<A>

Converts to this type from the input type.
§

impl<A> From<&UntypedHandle> for AssetId<A>where A: Asset,

§

fn from(value: &UntypedHandle) -> AssetId<A>

Converts to this type from the input type.
§

impl<A> From<AssetId<A>> for UntypedAssetIdwhere A: Asset,

§

fn from(value: AssetId<A>) -> UntypedAssetId

Converts to this type from the input type.
§

impl<A> From<AssetIndex> for AssetId<A>where A: Asset,

§

fn from(value: AssetIndex) -> AssetId<A>

Converts to this type from the input type.
§

impl<A> From<Handle<A>> for AssetId<A>where A: Asset,

§

fn from(value: Handle<A>) -> AssetId<A>

Converts to this type from the input type.
§

impl<A> From<UntypedAssetId> for AssetId<A>where A: Asset,

§

fn from(value: UntypedAssetId) -> AssetId<A>

Converts to this type from the input type.
§

impl<A> From<UntypedHandle> for AssetId<A>where A: Asset,

§

fn from(value: UntypedHandle) -> AssetId<A>

Converts to this type from the input type.
§

impl<A> From<Uuid> for AssetId<A>where A: Asset,

§

fn from(value: Uuid) -> AssetId<A>

Converts to this type from the input type.
§

impl<A> FromReflect for AssetId<A>where A: Asset + TypePath, AssetIndex: FromReflect + TypePath, Uuid: FromReflect + TypePath, PhantomData<fn() -> A>: Any + Send + Sync + Default,

§

fn from_reflect(__param0: &(dyn Reflect + 'static)) -> Option<AssetId<A>>

Constructs a concrete instance of Self from a reflected value.
§

fn take_from_reflect( reflect: Box<dyn Reflect> ) -> Result<Self, Box<dyn Reflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
§

impl<A> GetTypeRegistration for AssetId<A>where A: Asset + TypePath, AssetIndex: FromReflect + TypePath, Uuid: FromReflect + TypePath, PhantomData<fn() -> A>: Any + Send + Sync,

§

impl<A> Hash for AssetId<A>where A: Asset,

§

fn hash<H>(&self, state: &mut H)where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl<A> Ord for AssetId<A>where A: Asset,

§

fn cmp(&self, other: &AssetId<A>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
§

impl<A> PartialEq for AssetId<A>where A: Asset,

§

fn eq(&self, other: &AssetId<A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<A> PartialOrd for AssetId<A>where A: Asset,

§

fn partial_cmp(&self, other: &AssetId<A>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl<A> Reflect for AssetId<A>where A: Asset + TypePath, AssetIndex: FromReflect + TypePath, Uuid: FromReflect + TypePath, PhantomData<fn() -> A>: Any + Send + Sync,

§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
§

fn into_any(self: Box<AssetId<A>>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>.
§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the value as a &dyn Any.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the value as a &mut dyn Any.
§

fn into_reflect(self: Box<AssetId<A>>) -> Box<dyn Reflect>

Casts this type to a boxed reflected value.
§

fn as_reflect(&self) -> &(dyn Reflect + 'static)

Casts this type to a reflected value.
§

fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)

Casts this type to a mutable reflected value.
§

fn clone_value(&self) -> Box<dyn Reflect>

Clones the value as a Reflect trait object. Read more
§

fn set( &mut self, __value_param: Box<dyn Reflect> ) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
§

fn apply(&mut self, __value_param: &(dyn Reflect + 'static))

Applies a reflected value to this value. Read more
§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an enumeration of “kinds” of type. Read more
§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
§

fn reflect_owned(self: Box<AssetId<A>>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
§

fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>

Returns a “partial equality” comparison result. Read more
§

fn type_name(&self) -> &str

👎Deprecated since 0.12.0: view the method documentation to find alternatives to this method.
Returns the type path of the underlying type. Read more
§

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Debug formatter for the value. Read more
§

fn serializable(&self) -> Option<Serializable<'_>>

Returns a serializable version of the value. Read more
§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
§

impl<A> TypePath for AssetId<A>where A: Asset + TypePath, AssetIndex: FromReflect + TypePath, Uuid: FromReflect + TypePath, PhantomData<fn() -> A>: Any + Send + Sync,

§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
§

impl<A> Typed for AssetId<A>where A: Asset + TypePath, AssetIndex: FromReflect + TypePath, Uuid: FromReflect + TypePath, PhantomData<fn() -> A>: Any + Send + Sync,

§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.
§

impl<A> Copy for AssetId<A>where A: Asset,

§

impl<A> Eq for AssetId<A>where A: Asset,

Auto Trait Implementations§

§

impl<A> RefUnwindSafe for AssetId<A>

§

impl<A> Send for AssetId<A>

§

impl<A> Sync for AssetId<A>

§

impl<A> Unpin for AssetId<A>

§

impl<A> UnwindSafe for AssetId<A>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,

§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Comparable<K> for Qwhere Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DynEq for Twhere T: Any + Eq,

§

fn as_any(&self) -> &(dyn Any + 'static)

Casts the type to dyn Any.
§

fn dyn_eq(&self, other: &(dyn DynEq + 'static)) -> bool

This method tests for self and other values to be equal. Read more
§

impl<T> DynHash for Twhere T: DynEq + Hash,

§

fn as_dyn_eq(&self) -> &(dyn DynEq + 'static)

Casts the type to dyn Any.
§

fn dyn_hash(&self, state: &mut dyn Hasher)

Feeds this value into the given Hasher.
§

impl<T> DynamicTypePath for Twhere T: TypePath,

§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> FromWorld for Twhere T: Default,

§

fn from_world(_world: &mut World) -> T

Creates Self using data from the given World.
§

impl<T> GetPath for Twhere T: Reflect + ?Sized,

§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p> ) -> Result<&(dyn Reflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p> ) -> Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
§

fn path<'p, T>( &self, path: impl ReflectPath<'p> ) -> Result<&T, ReflectPathError<'p>>where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p> ) -> Result<&mut T, ReflectPathError<'p>>where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

impl<T> TypeData for Twhere T: 'static + Send + Sync + Clone,

§

fn clone_type_data(&self) -> Box<dyn TypeData>

§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,

source§

impl<N> NodeTrait for Nwhere N: Copy + Ord + Hash,

§

impl<T> Settings for Twhere T: 'static + Send + Sync,

§

impl<T> WasmNotSend for Twhere T: Send,

§

impl<T> WasmNotSync for Twhere T: Sync,