1use crate::{Asset, AssetId, AssetLoadError, AssetPath, UntypedAssetId};
2use bevy_ecs::message::Message;
3use bevy_reflect::Reflect;
4use core::fmt::Debug;
5
6#[derive(impl<A: Asset> bevy_ecs::message::Message for AssetLoadFailedEvent<A> where
Self: ::core::marker::Send + ::core::marker::Sync + 'static {}Message, #[automatically_derived]
impl<A: ::core::clone::Clone + Asset> ::core::clone::Clone for
AssetLoadFailedEvent<A> {
#[inline]
fn clone(&self) -> AssetLoadFailedEvent<A> {
AssetLoadFailedEvent {
id: ::core::clone::Clone::clone(&self.id),
path: ::core::clone::Clone::clone(&self.path),
error: ::core::clone::Clone::clone(&self.error),
}
}
}Clone, #[automatically_derived]
impl<A: ::core::fmt::Debug + Asset> ::core::fmt::Debug for
AssetLoadFailedEvent<A> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"AssetLoadFailedEvent", "id", &self.id, "path", &self.path,
"error", &&self.error)
}
}Debug)]
10pub struct AssetLoadFailedEvent<A: Asset> {
11 pub id: AssetId<A>,
13 pub path: AssetPath<'static>,
15 pub error: AssetLoadError,
17}
18
19impl<A: Asset> AssetLoadFailedEvent<A> {
20 pub fn untyped(&self) -> UntypedAssetLoadFailedEvent {
22 self.into()
23 }
24}
25
26#[derive(impl bevy_ecs::message::Message for UntypedAssetLoadFailedEvent where
Self: ::core::marker::Send + ::core::marker::Sync + 'static {}Message, #[automatically_derived]
impl ::core::clone::Clone for UntypedAssetLoadFailedEvent {
#[inline]
fn clone(&self) -> UntypedAssetLoadFailedEvent {
UntypedAssetLoadFailedEvent {
id: ::core::clone::Clone::clone(&self.id),
path: ::core::clone::Clone::clone(&self.path),
error: ::core::clone::Clone::clone(&self.error),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for UntypedAssetLoadFailedEvent {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"UntypedAssetLoadFailedEvent", "id", &self.id, "path", &self.path,
"error", &&self.error)
}
}Debug)]
28pub struct UntypedAssetLoadFailedEvent {
29 pub id: UntypedAssetId,
31 pub path: AssetPath<'static>,
33 pub error: AssetLoadError,
35}
36
37impl<A: Asset> From<&AssetLoadFailedEvent<A>> for UntypedAssetLoadFailedEvent {
38 fn from(value: &AssetLoadFailedEvent<A>) -> Self {
39 UntypedAssetLoadFailedEvent {
40 id: value.id.untyped(),
41 path: value.path.clone(),
42 error: value.error.clone(),
43 }
44 }
45}
46
47#[expect(missing_docs, reason = "Documenting the id fields is unhelpful.")]
49#[derive(impl<A: Asset> bevy_ecs::message::Message for AssetEvent<A> where
Self: ::core::marker::Send + ::core::marker::Sync + 'static {}Message, const _: () =
{
impl<A: Asset> bevy_reflect::GetTypeRegistration for AssetEvent<A>
where AssetEvent<A>: ::core::any::Any + ::core::marker::Send +
::core::marker::Sync, A: bevy_reflect::TypePath,
AssetId<A>: bevy_reflect::FromReflect + bevy_reflect::TypePath +
bevy_reflect::MaybeTyped +
bevy_reflect::__macro_exports::RegisterForReflection {
fn get_type_registration() -> bevy_reflect::TypeRegistration {
let mut registration =
bevy_reflect::TypeRegistration::of::<Self>();
registration.insert::<bevy_reflect::ReflectFromPtr>(bevy_reflect::FromType::<Self>::from_type());
registration.insert::<bevy_reflect::ReflectFromReflect>(bevy_reflect::FromType::<Self>::from_type());
registration
}
#[inline(never)]
fn register_type_dependencies(registry:
&mut bevy_reflect::TypeRegistry) {
<AssetId<A> as
bevy_reflect::__macro_exports::RegisterForReflection>::__register(registry);
}
}
impl<A: Asset> bevy_reflect::Typed for AssetEvent<A> where
AssetEvent<A>: ::core::any::Any + ::core::marker::Send +
::core::marker::Sync, A: bevy_reflect::TypePath,
AssetId<A>: bevy_reflect::FromReflect + bevy_reflect::TypePath +
bevy_reflect::MaybeTyped +
bevy_reflect::__macro_exports::RegisterForReflection {
#[inline]
fn type_info() -> &'static bevy_reflect::TypeInfo {
static CELL: bevy_reflect::utility::GenericTypeInfoCell =
bevy_reflect::utility::GenericTypeInfoCell::new();
CELL.get_or_insert::<Self,
_>(||
{
bevy_reflect::TypeInfo::Enum(bevy_reflect::enums::EnumInfo::new::<Self>(&[bevy_reflect::enums::VariantInfo::Struct(bevy_reflect::enums::StructVariantInfo::new("Added",
&[bevy_reflect::NamedField::new::<AssetId<A>>("id")])),
bevy_reflect::enums::VariantInfo::Struct(bevy_reflect::enums::StructVariantInfo::new("Modified",
&[bevy_reflect::NamedField::new::<AssetId<A>>("id")])),
bevy_reflect::enums::VariantInfo::Struct(bevy_reflect::enums::StructVariantInfo::new("Removed",
&[bevy_reflect::NamedField::new::<AssetId<A>>("id")])),
bevy_reflect::enums::VariantInfo::Struct(bevy_reflect::enums::StructVariantInfo::new("Unused",
&[bevy_reflect::NamedField::new::<AssetId<A>>("id")])),
bevy_reflect::enums::VariantInfo::Struct(bevy_reflect::enums::StructVariantInfo::new("LoadedWithDependencies",
&[bevy_reflect::NamedField::new::<AssetId<A>>("id")]))]).with_generics(bevy_reflect::Generics::from_iter([bevy_reflect::GenericInfo::Type(bevy_reflect::TypeParamInfo::new::<A>(bevy_reflect::__macro_exports::alloc_utils::Cow::Borrowed("A")))])))
})
}
}
#[allow(deprecated, reason =
"derives on a deprecated type shouldn't be considered a usage")]
impl<A: Asset> bevy_reflect::TypePath for AssetEvent<A> where
AssetEvent<A>: ::core::any::Any + ::core::marker::Send +
::core::marker::Sync, A: bevy_reflect::TypePath {
fn type_path() -> &'static str {
static CELL: bevy_reflect::utility::GenericTypePathCell =
bevy_reflect::utility::GenericTypePathCell::new();
CELL.get_or_insert::<Self,
_>(||
{
::core::ops::Add::<&str>::add(::core::ops::Add::<&str>::add(bevy_reflect::__macro_exports::alloc_utils::ToString::to_string("bevy_asset::event::AssetEvent<"),
<A as bevy_reflect::TypePath>::type_path()), ">")
})
}
fn short_type_path() -> &'static str {
static CELL: bevy_reflect::utility::GenericTypePathCell =
bevy_reflect::utility::GenericTypePathCell::new();
CELL.get_or_insert::<Self,
_>(||
{
::core::ops::Add::<&str>::add(::core::ops::Add::<&str>::add(bevy_reflect::__macro_exports::alloc_utils::ToString::to_string("AssetEvent<"),
<A as bevy_reflect::TypePath>::short_type_path()), ">")
})
}
fn type_ident() -> ::core::option::Option<&'static str> {
::core::option::Option::Some("AssetEvent")
}
fn crate_name() -> ::core::option::Option<&'static str> {
::core::option::Option::Some("bevy_asset::event".split(':').next().unwrap())
}
fn module_path() -> ::core::option::Option<&'static str> {
::core::option::Option::Some("bevy_asset::event")
}
}
impl<A: Asset> bevy_reflect::Reflect for AssetEvent<A> where
AssetEvent<A>: ::core::any::Any + ::core::marker::Send +
::core::marker::Sync, A: bevy_reflect::TypePath,
AssetId<A>: bevy_reflect::FromReflect + bevy_reflect::TypePath +
bevy_reflect::MaybeTyped +
bevy_reflect::__macro_exports::RegisterForReflection {
#[inline]
fn into_any(self:
bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
->
bevy_reflect::__macro_exports::alloc_utils::Box<dyn ::core::any::Any> {
self
}
#[inline]
fn as_any(&self) -> &dyn ::core::any::Any { self }
#[inline]
fn as_any_mut(&mut self) -> &mut dyn ::core::any::Any { self }
#[inline]
fn into_reflect(self:
bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
->
bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect> {
self
}
#[inline]
fn as_reflect(&self) -> &dyn bevy_reflect::Reflect { self }
#[inline]
fn as_reflect_mut(&mut self) -> &mut dyn bevy_reflect::Reflect {
self
}
#[inline]
fn set(&mut self,
value:
bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>)
->
::core::result::Result<(),
bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>> {
*self = <dyn bevy_reflect::Reflect>::take(value)?;
::core::result::Result::Ok(())
}
}
impl<A: Asset> bevy_reflect::enums::Enum for AssetEvent<A> where
AssetEvent<A>: ::core::any::Any + ::core::marker::Send +
::core::marker::Sync, A: bevy_reflect::TypePath,
AssetId<A>: bevy_reflect::FromReflect + bevy_reflect::TypePath +
bevy_reflect::MaybeTyped +
bevy_reflect::__macro_exports::RegisterForReflection {
fn field(&self, __name_param: &str)
-> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
match self {
AssetEvent::Added { id: __value, .. } if
__name_param == "id" =>
::core::option::Option::Some(__value),
AssetEvent::Modified { id: __value, .. } if
__name_param == "id" =>
::core::option::Option::Some(__value),
AssetEvent::Removed { id: __value, .. } if
__name_param == "id" =>
::core::option::Option::Some(__value),
AssetEvent::Unused { id: __value, .. } if
__name_param == "id" =>
::core::option::Option::Some(__value),
AssetEvent::LoadedWithDependencies { id: __value, .. } if
__name_param == "id" =>
::core::option::Option::Some(__value),
_ => ::core::option::Option::None,
}
}
fn field_at(&self, __index_param: usize)
-> ::core::option::Option<&dyn bevy_reflect::PartialReflect> {
match self {
AssetEvent::Added { id: __value, .. } if
__index_param == 0usize =>
::core::option::Option::Some(__value),
AssetEvent::Modified { id: __value, .. } if
__index_param == 0usize =>
::core::option::Option::Some(__value),
AssetEvent::Removed { id: __value, .. } if
__index_param == 0usize =>
::core::option::Option::Some(__value),
AssetEvent::Unused { id: __value, .. } if
__index_param == 0usize =>
::core::option::Option::Some(__value),
AssetEvent::LoadedWithDependencies { id: __value, .. } if
__index_param == 0usize =>
::core::option::Option::Some(__value),
_ => ::core::option::Option::None,
}
}
fn field_mut(&mut self, __name_param: &str)
->
::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
match self {
AssetEvent::Added { id: __value, .. } if
__name_param == "id" =>
::core::option::Option::Some(__value),
AssetEvent::Modified { id: __value, .. } if
__name_param == "id" =>
::core::option::Option::Some(__value),
AssetEvent::Removed { id: __value, .. } if
__name_param == "id" =>
::core::option::Option::Some(__value),
AssetEvent::Unused { id: __value, .. } if
__name_param == "id" =>
::core::option::Option::Some(__value),
AssetEvent::LoadedWithDependencies { id: __value, .. } if
__name_param == "id" =>
::core::option::Option::Some(__value),
_ => ::core::option::Option::None,
}
}
fn field_at_mut(&mut self, __index_param: usize)
->
::core::option::Option<&mut dyn bevy_reflect::PartialReflect> {
match self {
AssetEvent::Added { id: __value, .. } if
__index_param == 0usize =>
::core::option::Option::Some(__value),
AssetEvent::Modified { id: __value, .. } if
__index_param == 0usize =>
::core::option::Option::Some(__value),
AssetEvent::Removed { id: __value, .. } if
__index_param == 0usize =>
::core::option::Option::Some(__value),
AssetEvent::Unused { id: __value, .. } if
__index_param == 0usize =>
::core::option::Option::Some(__value),
AssetEvent::LoadedWithDependencies { id: __value, .. } if
__index_param == 0usize =>
::core::option::Option::Some(__value),
_ => ::core::option::Option::None,
}
}
fn index_of(&self, __name_param: &str)
-> ::core::option::Option<usize> {
match self {
AssetEvent::Added { .. } if __name_param == "id" =>
::core::option::Option::Some(0usize),
AssetEvent::Modified { .. } if __name_param == "id" =>
::core::option::Option::Some(0usize),
AssetEvent::Removed { .. } if __name_param == "id" =>
::core::option::Option::Some(0usize),
AssetEvent::Unused { .. } if __name_param == "id" =>
::core::option::Option::Some(0usize),
AssetEvent::LoadedWithDependencies { .. } if
__name_param == "id" =>
::core::option::Option::Some(0usize),
_ => ::core::option::Option::None,
}
}
fn name_at(&self, __index_param: usize)
-> ::core::option::Option<&str> {
match self {
AssetEvent::Added { .. } if __index_param == 0usize =>
::core::option::Option::Some("id"),
AssetEvent::Modified { .. } if __index_param == 0usize =>
::core::option::Option::Some("id"),
AssetEvent::Removed { .. } if __index_param == 0usize =>
::core::option::Option::Some("id"),
AssetEvent::Unused { .. } if __index_param == 0usize =>
::core::option::Option::Some("id"),
AssetEvent::LoadedWithDependencies { .. } if
__index_param == 0usize =>
::core::option::Option::Some("id"),
_ => ::core::option::Option::None,
}
}
fn iter_fields(&self) -> bevy_reflect::enums::VariantFieldIter {
bevy_reflect::enums::VariantFieldIter::new(self)
}
#[inline]
fn field_len(&self) -> usize {
match self {
AssetEvent::Added { .. } => 1usize,
AssetEvent::Modified { .. } => 1usize,
AssetEvent::Removed { .. } => 1usize,
AssetEvent::Unused { .. } => 1usize,
AssetEvent::LoadedWithDependencies { .. } => 1usize,
_ => 0,
}
}
#[inline]
fn variant_name(&self) -> &str {
match self {
AssetEvent::Added { .. } => "Added",
AssetEvent::Modified { .. } => "Modified",
AssetEvent::Removed { .. } => "Removed",
AssetEvent::Unused { .. } => "Unused",
AssetEvent::LoadedWithDependencies { .. } =>
"LoadedWithDependencies",
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
#[inline]
fn variant_index(&self) -> usize {
match self {
AssetEvent::Added { .. } => 0usize,
AssetEvent::Modified { .. } => 1usize,
AssetEvent::Removed { .. } => 2usize,
AssetEvent::Unused { .. } => 3usize,
AssetEvent::LoadedWithDependencies { .. } => 4usize,
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
#[inline]
fn variant_type(&self) -> bevy_reflect::enums::VariantType {
match self {
AssetEvent::Added { .. } =>
bevy_reflect::enums::VariantType::Struct,
AssetEvent::Modified { .. } =>
bevy_reflect::enums::VariantType::Struct,
AssetEvent::Removed { .. } =>
bevy_reflect::enums::VariantType::Struct,
AssetEvent::Unused { .. } =>
bevy_reflect::enums::VariantType::Struct,
AssetEvent::LoadedWithDependencies { .. } =>
bevy_reflect::enums::VariantType::Struct,
_ =>
::core::panicking::panic("internal error: entered unreachable code"),
}
}
fn to_dynamic_enum(&self) -> bevy_reflect::enums::DynamicEnum {
bevy_reflect::enums::DynamicEnum::from_ref::<Self>(self)
}
}
impl<A: Asset> bevy_reflect::PartialReflect for AssetEvent<A> where
AssetEvent<A>: ::core::any::Any + ::core::marker::Send +
::core::marker::Sync, A: bevy_reflect::TypePath,
AssetId<A>: bevy_reflect::FromReflect + bevy_reflect::TypePath +
bevy_reflect::MaybeTyped +
bevy_reflect::__macro_exports::RegisterForReflection {
#[inline]
fn get_represented_type_info(&self)
-> ::core::option::Option<&'static bevy_reflect::TypeInfo> {
::core::option::Option::Some(<Self as
bevy_reflect::Typed>::type_info())
}
#[inline]
fn try_apply(&mut self,
__value_param: &dyn bevy_reflect::PartialReflect)
-> ::core::result::Result<(), bevy_reflect::ApplyError> {
if let bevy_reflect::ReflectRef::Enum(__value_param) =
bevy_reflect::PartialReflect::reflect_ref(__value_param) {
if bevy_reflect::enums::Enum::variant_name(self) ==
bevy_reflect::enums::Enum::variant_name(__value_param) {
match bevy_reflect::enums::Enum::variant_type(__value_param)
{
bevy_reflect::enums::VariantType::Struct => {
for field in
bevy_reflect::enums::Enum::iter_fields(__value_param) {
let name = field.name().unwrap();
if let ::core::option::Option::Some(v) =
bevy_reflect::enums::Enum::field_mut(self, name) {
bevy_reflect::PartialReflect::try_apply(v, field.value())?;
}
}
}
bevy_reflect::enums::VariantType::Tuple => {
for (index, field) in
::core::iter::Iterator::enumerate(bevy_reflect::enums::Enum::iter_fields(__value_param))
{
if let ::core::option::Option::Some(v) =
bevy_reflect::enums::Enum::field_at_mut(self, index) {
bevy_reflect::PartialReflect::try_apply(v, field.value())?;
}
}
}
_ => {}
}
} else {
match bevy_reflect::enums::Enum::variant_name(__value_param)
{
"Added" => {
*self =
AssetEvent::Added {
id: {
let __id = __value_param.field("id");
let __id =
__id.ok_or(bevy_reflect::ApplyError::MissingEnumField {
variant_name: ::core::convert::Into::into("Added"),
field_name: ::core::convert::Into::into("id"),
})?;
<AssetId<A> as
bevy_reflect::FromReflect>::from_reflect(__id).ok_or(bevy_reflect::ApplyError::MismatchedTypes {
from_type: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(__id)),
to_type: ::core::convert::Into::into(<AssetId<A> as
bevy_reflect::TypePath>::type_path()),
})?
},
}
}
"Modified" => {
*self =
AssetEvent::Modified {
id: {
let __id = __value_param.field("id");
let __id =
__id.ok_or(bevy_reflect::ApplyError::MissingEnumField {
variant_name: ::core::convert::Into::into("Modified"),
field_name: ::core::convert::Into::into("id"),
})?;
<AssetId<A> as
bevy_reflect::FromReflect>::from_reflect(__id).ok_or(bevy_reflect::ApplyError::MismatchedTypes {
from_type: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(__id)),
to_type: ::core::convert::Into::into(<AssetId<A> as
bevy_reflect::TypePath>::type_path()),
})?
},
}
}
"Removed" => {
*self =
AssetEvent::Removed {
id: {
let __id = __value_param.field("id");
let __id =
__id.ok_or(bevy_reflect::ApplyError::MissingEnumField {
variant_name: ::core::convert::Into::into("Removed"),
field_name: ::core::convert::Into::into("id"),
})?;
<AssetId<A> as
bevy_reflect::FromReflect>::from_reflect(__id).ok_or(bevy_reflect::ApplyError::MismatchedTypes {
from_type: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(__id)),
to_type: ::core::convert::Into::into(<AssetId<A> as
bevy_reflect::TypePath>::type_path()),
})?
},
}
}
"Unused" => {
*self =
AssetEvent::Unused {
id: {
let __id = __value_param.field("id");
let __id =
__id.ok_or(bevy_reflect::ApplyError::MissingEnumField {
variant_name: ::core::convert::Into::into("Unused"),
field_name: ::core::convert::Into::into("id"),
})?;
<AssetId<A> as
bevy_reflect::FromReflect>::from_reflect(__id).ok_or(bevy_reflect::ApplyError::MismatchedTypes {
from_type: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(__id)),
to_type: ::core::convert::Into::into(<AssetId<A> as
bevy_reflect::TypePath>::type_path()),
})?
},
}
}
"LoadedWithDependencies" => {
*self =
AssetEvent::LoadedWithDependencies {
id: {
let __id = __value_param.field("id");
let __id =
__id.ok_or(bevy_reflect::ApplyError::MissingEnumField {
variant_name: ::core::convert::Into::into("LoadedWithDependencies"),
field_name: ::core::convert::Into::into("id"),
})?;
<AssetId<A> as
bevy_reflect::FromReflect>::from_reflect(__id).ok_or(bevy_reflect::ApplyError::MismatchedTypes {
from_type: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(__id)),
to_type: ::core::convert::Into::into(<AssetId<A> as
bevy_reflect::TypePath>::type_path()),
})?
},
}
}
name => {
return ::core::result::Result::Err(bevy_reflect::ApplyError::UnknownVariant {
enum_name: ::core::convert::Into::into(bevy_reflect::DynamicTypePath::reflect_type_path(self)),
variant_name: ::core::convert::Into::into(name),
});
}
}
}
} else {
return ::core::result::Result::Err(bevy_reflect::ApplyError::MismatchedKinds {
from_kind: bevy_reflect::PartialReflect::reflect_kind(__value_param),
to_kind: bevy_reflect::ReflectKind::Enum,
});
}
::core::result::Result::Ok(())
}
fn reflect_kind(&self) -> bevy_reflect::ReflectKind {
bevy_reflect::ReflectKind::Enum
}
fn reflect_ref(&self) -> bevy_reflect::ReflectRef {
bevy_reflect::ReflectRef::Enum(self)
}
fn reflect_mut(&mut self) -> bevy_reflect::ReflectMut {
bevy_reflect::ReflectMut::Enum(self)
}
fn reflect_owned(self:
bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
-> bevy_reflect::ReflectOwned {
bevy_reflect::ReflectOwned::Enum(self)
}
#[inline]
fn try_into_reflect(self:
bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
->
::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect>> {
::core::result::Result::Ok(self)
}
#[inline]
fn try_as_reflect(&self)
-> ::core::option::Option<&dyn bevy_reflect::Reflect> {
::core::option::Option::Some(self)
}
#[inline]
fn try_as_reflect_mut(&mut self)
-> ::core::option::Option<&mut dyn bevy_reflect::Reflect> {
::core::option::Option::Some(self)
}
#[inline]
fn into_partial_reflect(self:
bevy_reflect::__macro_exports::alloc_utils::Box<Self>)
->
bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::PartialReflect> {
self
}
#[inline]
fn as_partial_reflect(&self)
-> &dyn bevy_reflect::PartialReflect {
self
}
#[inline]
fn as_partial_reflect_mut(&mut self)
-> &mut dyn bevy_reflect::PartialReflect {
self
}
fn reflect_hash(&self) -> ::core::option::Option<u64> {
(bevy_reflect::enums::enum_hash)(self)
}
fn reflect_partial_eq(&self,
value: &dyn bevy_reflect::PartialReflect)
-> ::core::option::Option<bool> {
(bevy_reflect::enums::enum_partial_eq)(self, value)
}
fn reflect_partial_cmp(&self,
value: &dyn bevy_reflect::PartialReflect)
-> ::core::option::Option<::core::cmp::Ordering> {
(bevy_reflect::enums::enum_partial_cmp)(self, value)
}
#[inline]
#[allow(unreachable_code, reason =
"Ignored fields without a `clone` attribute will early-return with an error")]
fn reflect_clone(&self)
->
::core::result::Result<bevy_reflect::__macro_exports::alloc_utils::Box<dyn bevy_reflect::Reflect>,
bevy_reflect::ReflectCloneError> {
let this = self;
::core::result::Result::Ok(bevy_reflect::__macro_exports::alloc_utils::Box::new(match this
{
AssetEvent::Added { id: __id } =>
AssetEvent::Added {
id: <AssetId<A> as
bevy_reflect::PartialReflect>::reflect_clone_and_take(__id)?,
},
AssetEvent::Modified { id: __id } =>
AssetEvent::Modified {
id: <AssetId<A> as
bevy_reflect::PartialReflect>::reflect_clone_and_take(__id)?,
},
AssetEvent::Removed { id: __id } =>
AssetEvent::Removed {
id: <AssetId<A> as
bevy_reflect::PartialReflect>::reflect_clone_and_take(__id)?,
},
AssetEvent::Unused { id: __id } =>
AssetEvent::Unused {
id: <AssetId<A> as
bevy_reflect::PartialReflect>::reflect_clone_and_take(__id)?,
},
AssetEvent::LoadedWithDependencies { id: __id } =>
AssetEvent::LoadedWithDependencies {
id: <AssetId<A> as
bevy_reflect::PartialReflect>::reflect_clone_and_take(__id)?,
},
}))
}
}
impl<A: Asset> bevy_reflect::FromReflect for AssetEvent<A> where
AssetEvent<A>: ::core::any::Any + ::core::marker::Send +
::core::marker::Sync, A: bevy_reflect::TypePath,
AssetId<A>: bevy_reflect::FromReflect + bevy_reflect::TypePath +
bevy_reflect::MaybeTyped +
bevy_reflect::__macro_exports::RegisterForReflection {
fn from_reflect(__param0: &dyn bevy_reflect::PartialReflect)
-> ::core::option::Option<Self> {
if let bevy_reflect::ReflectRef::Enum(__param0) =
bevy_reflect::PartialReflect::reflect_ref(__param0) {
match bevy_reflect::enums::Enum::variant_name(__param0) {
"Added" =>
::core::option::Option::Some(AssetEvent::Added {
id: {
let __id = __param0.field("id");
let __id = __id?;
<AssetId<A> as
bevy_reflect::FromReflect>::from_reflect(__id)?
},
}),
"Modified" =>
::core::option::Option::Some(AssetEvent::Modified {
id: {
let __id = __param0.field("id");
let __id = __id?;
<AssetId<A> as
bevy_reflect::FromReflect>::from_reflect(__id)?
},
}),
"Removed" =>
::core::option::Option::Some(AssetEvent::Removed {
id: {
let __id = __param0.field("id");
let __id = __id?;
<AssetId<A> as
bevy_reflect::FromReflect>::from_reflect(__id)?
},
}),
"Unused" =>
::core::option::Option::Some(AssetEvent::Unused {
id: {
let __id = __param0.field("id");
let __id = __id?;
<AssetId<A> as
bevy_reflect::FromReflect>::from_reflect(__id)?
},
}),
"LoadedWithDependencies" =>
::core::option::Option::Some(AssetEvent::LoadedWithDependencies {
id: {
let __id = __param0.field("id");
let __id = __id?;
<AssetId<A> as
bevy_reflect::FromReflect>::from_reflect(__id)?
},
}),
name => ::core::option::Option::None,
}
} else { ::core::option::Option::None }
}
}
};Reflect)]
50pub enum AssetEvent<A: Asset> {
51 Added { id: AssetId<A> },
53 Modified { id: AssetId<A> },
55 Removed { id: AssetId<A> },
57 Unused { id: AssetId<A> },
59 LoadedWithDependencies { id: AssetId<A> },
61}
62
63impl<A: Asset> AssetEvent<A> {
64 pub fn is_loaded_with_dependencies(&self, asset_id: impl Into<AssetId<A>>) -> bool {
66 #[allow(non_exhaustive_omitted_patterns)] match self {
AssetEvent::LoadedWithDependencies { id } if *id == asset_id.into() =>
true,
_ => false,
}matches!(self, AssetEvent::LoadedWithDependencies { id } if *id == asset_id.into())
67 }
68
69 pub fn is_added(&self, asset_id: impl Into<AssetId<A>>) -> bool {
71 #[allow(non_exhaustive_omitted_patterns)] match self {
AssetEvent::Added { id } if *id == asset_id.into() => true,
_ => false,
}matches!(self, AssetEvent::Added { id } if *id == asset_id.into())
72 }
73
74 pub fn is_modified(&self, asset_id: impl Into<AssetId<A>>) -> bool {
76 #[allow(non_exhaustive_omitted_patterns)] match self {
AssetEvent::Modified { id } if *id == asset_id.into() => true,
_ => false,
}matches!(self, AssetEvent::Modified { id } if *id == asset_id.into())
77 }
78
79 pub fn is_removed(&self, asset_id: impl Into<AssetId<A>>) -> bool {
81 #[allow(non_exhaustive_omitted_patterns)] match self {
AssetEvent::Removed { id } if *id == asset_id.into() => true,
_ => false,
}matches!(self, AssetEvent::Removed { id } if *id == asset_id.into())
82 }
83
84 pub fn is_unused(&self, asset_id: impl Into<AssetId<A>>) -> bool {
86 #[allow(non_exhaustive_omitted_patterns)] match self {
AssetEvent::Unused { id } if *id == asset_id.into() => true,
_ => false,
}matches!(self, AssetEvent::Unused { id } if *id == asset_id.into())
87 }
88}
89
90impl<A: Asset> Clone for AssetEvent<A> {
91 fn clone(&self) -> Self {
92 *self
93 }
94}
95
96impl<A: Asset> Copy for AssetEvent<A> {}
97
98impl<A: Asset> Debug for AssetEvent<A> {
99 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
100 match self {
101 Self::Added { id } => f.debug_struct("Added").field("id", id).finish(),
102 Self::Modified { id } => f.debug_struct("Modified").field("id", id).finish(),
103 Self::Removed { id } => f.debug_struct("Removed").field("id", id).finish(),
104 Self::Unused { id } => f.debug_struct("Unused").field("id", id).finish(),
105 Self::LoadedWithDependencies { id } => f
106 .debug_struct("LoadedWithDependencies")
107 .field("id", id)
108 .finish(),
109 }
110 }
111}
112
113impl<A: Asset> PartialEq for AssetEvent<A> {
114 fn eq(&self, other: &Self) -> bool {
115 match (self, other) {
116 (Self::Added { id: l_id }, Self::Added { id: r_id })
117 | (Self::Modified { id: l_id }, Self::Modified { id: r_id })
118 | (Self::Removed { id: l_id }, Self::Removed { id: r_id })
119 | (Self::Unused { id: l_id }, Self::Unused { id: r_id })
120 | (
121 Self::LoadedWithDependencies { id: l_id },
122 Self::LoadedWithDependencies { id: r_id },
123 ) => l_id == r_id,
124 _ => false,
125 }
126 }
127}
128
129impl<A: Asset> Eq for AssetEvent<A> {}