Enum MaterialRef
pub enum MaterialRef {
Inline {
material: Box<dyn Material>,
uuid: AssetUUID,
},
Asset(AssetUUID),
}Expand description
Authored reference to a material — the only serialized material form.
The enum is the discriminator: Inline embeds the material value,
Asset carries the stable UUID of a .kmat in the VFS.
Both arms carry an identity UUID — the content-derived UUID for Inline,
the stable asset UUID for Asset. The resolver compares this identity
against the resolved handle’s UUID every tick: a mismatch (or a missing
handle) means the authored reference changed and must be re-resolved. The
Inline UUID is never serialized; it is recomputed from the material
content on deserialize via MaterialRef::inline so it stays purely
content-derived. Construct Inline through MaterialRef::inline so the
UUID and the material value can never disagree.
Variants§
Inline
Ad-hoc material data created in code or the editor, embedded inline.
The uuid is content-derived; build via MaterialRef::inline.
Fields
Asset(AssetUUID)
Reference to a .kmat asset in the VFS, resolved by UUID.
Implementations§
§impl MaterialRef
impl MaterialRef
pub fn inline(material: Box<dyn Material>) -> MaterialRef
pub fn inline(material: Box<dyn Material>) -> MaterialRef
Builds an Inline reference from a material value, deriving its identity
UUID from the material content. Two inline references holding equal
material content get the same UUID, so they dedup to one resolved handle
(and one GpuMaterial). On a serialization failure the UUID falls back
to a fresh random value (logged) rather than panicking.
Trait Implementations§
§impl Clone for MaterialRef
impl Clone for MaterialRef
§fn clone(&self) -> MaterialRef
fn clone(&self) -> MaterialRef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Component for MaterialRef
impl Component for MaterialRef
§fn make_column() -> Box<dyn AnyVec>where
Self: Sized,
fn make_column() -> Box<dyn AnyVec>where
Self: Sized,
Vec<Self>.§fn push_into_column(self, column: &mut (dyn AnyVec + 'static))where
Self: Sized,
fn push_into_column(self, column: &mut (dyn AnyVec + 'static))where
Self: Sized,
self as a new row into its column. Read more§fn copy_row_between(
src: &(dyn AnyVec + 'static),
src_row: usize,
dst: &mut (dyn AnyVec + 'static),
)where
Self: Sized,
fn copy_row_between(
src: &(dyn AnyVec + 'static),
src_row: usize,
dst: &mut (dyn AnyVec + 'static),
)where
Self: Sized,
src_row from src into dst (used when an entity migrates
between pages on a structural change). Both columns are this component’s
column type. Read more§fn clone_from_column(column: &(dyn AnyVec + 'static), row: usize) -> Selfwhere
Self: Sized,
fn clone_from_column(column: &(dyn AnyVec + 'static), row: usize) -> Selfwhere
Self: Sized,
row of column as an owned value — the uniform by-value
access path that works for both AoS (clone the &T) and field-SoA
(gather the fields) layouts. Used by World::clone_component, the
Soa<T> query, and the serialization recipe. Read more§fn set_in_column(self, column: &mut (dyn AnyVec + 'static), row: usize)where
Self: Sized,
fn set_in_column(self, column: &mut (dyn AnyVec + 'static), row: usize)where
Self: Sized,
row of column with self — the uniform by-value write
path for both layouts (AoS assigns the slot; field-SoA scatters into the
lanes). Used by World::set_component. Read moreAuto Trait Implementations§
impl Freeze for MaterialRef
impl !RefUnwindSafe for MaterialRef
impl Send for MaterialRef
impl Sync for MaterialRef
impl Unpin for MaterialRef
impl UnsafeUnpin for MaterialRef
impl !UnwindSafe for MaterialRef
Blanket Implementations§
§impl<T> AppLifecycle for Twhere
T: ?Sized,
impl<T> AppLifecycle for Twhere
T: ?Sized,
§fn on_start(&mut self, ctx: &mut dyn AppContext)
fn on_start(&mut self, ctx: &mut dyn AppContext)
update. Apps install their theme / fonts here.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C1> ComponentBundle for C1where
C1: Component,
impl<C1> ComponentBundle for C1where
C1: Component,
§fn type_ids() -> Vec<TypeId>
fn type_ids() -> Vec<TypeId>
TypeIds for the components in this bundle. Read more§fn create_columns() -> HashMap<TypeId, Box<dyn AnyVec>>
fn create_columns() -> HashMap<TypeId, Box<dyn AnyVec>>
Vec<T> columns required to store
this bundle’s components. Read more§fn update_metadata(
metadata: &mut EntityMetadata,
location: PageIndex,
registry: &ComponentRegistry,
)
fn update_metadata( metadata: &mut EntityMetadata, location: PageIndex, registry: &ComponentRegistry, )
EntityMetadata struct to point
to the location of this bundle’s data. Read more§unsafe fn add_to_page(self, page: &mut ComponentPage)
unsafe fn add_to_page(self, page: &mut ComponentPage)
ComponentPage. Read more§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§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>
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>
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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.