Struct bones_ecs::prelude::SchemaRefMut
pub struct SchemaRefMut<'pointer> { /* private fields */ }
Expand description
An untyped mutable reference that knows the [Schema
] of the pointee and that can be cast to a matching
type.
Implementations§
§impl<'pointer> SchemaRefMut<'pointer>
impl<'pointer> SchemaRefMut<'pointer>
pub unsafe fn cast_mut_unchecked<T>(&mut self) -> &mut T
pub unsafe fn cast_mut_unchecked<T>(&mut self) -> &mut T
Cast this pointer to a mutable reference.
§Safety
You must uphold all safety requirements of NonNull::as_mut()
.
pub unsafe fn cast_into_mut_unchecked<T>(self) -> &'pointer mut T
pub unsafe fn cast_into_mut_unchecked<T>(self) -> &'pointer mut T
Cast this pointer to a mutable reference.
§Safety
You must uphold all safety requirements of NonNull::as_mut()
.
pub fn cast_mut<T>(&mut self) -> &mut Twhere
T: HasSchema + 'static,
pub fn cast_mut<T>(&mut self) -> &mut Twhere
T: HasSchema + 'static,
Cast this pointer to a reference to a type with a matching [Schema
].
§Panics
Panics if the schema of the pointer does not match that of the type you are casting to.
pub fn try_cast_mut<T>(&mut self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
pub fn try_cast_mut<T>(&mut self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
Cast this pointer to a mutable reference to a type with a matching [Schema
].
§Errors
Errors if the schema of the pointer does not match that of the type you are casting to.
pub fn cast_into_mut<T>(self) -> &'pointer mut Twhere
T: HasSchema,
pub fn cast_into_mut<T>(self) -> &'pointer mut Twhere
T: HasSchema,
Cast this pointer to a mutable reference to a type with a matching [Schema
]. This is
different than try_cast
because it consumes the SchemaRefMut
and allows you to, for
instance, pass it out of a mapping operation without keeping a reference to the old
SchemaRefMut
.
§Panics
Panics if the schema of the pointer does not match that of the type you are casting to.
pub fn try_cast_into_mut<T>(
self,
) -> Result<&'pointer mut T, SchemaMismatchError>where
T: HasSchema,
pub fn try_cast_into_mut<T>(
self,
) -> Result<&'pointer mut T, SchemaMismatchError>where
T: HasSchema,
Cast this pointer to a mutable reference to a type with a matching [Schema
]. This is
different than try_cast
because it consumes the SchemaRefMut
and allows you to, for
instance, pass it out of a mapping operation without keeping a reference to the old
SchemaRefMut
.
§Errors
Errors if the schema of the pointer does not match that of the type you are casting to.
pub fn new<T>(v: &'pointer mut T) -> SchemaRefMut<'pointer>where
T: HasSchema,
pub fn new<T>(v: &'pointer mut T) -> SchemaRefMut<'pointer>where
T: HasSchema,
Create a new SchemaRefMut
from a reference to a type that implements HasSchema
.
pub unsafe fn from_ptr_schema(
ptr: *mut c_void,
schema: &'static Schema,
) -> SchemaRefMut<'pointer>
pub unsafe fn from_ptr_schema( ptr: *mut c_void, schema: &'static Schema, ) -> SchemaRefMut<'pointer>
Create a new SchemaRefMut
from a raw pointer and it’s schema.
§Safety
- The pointee of
ptr
must be accurately described by the givenschema
. inner
must have correct provenance to allow reads and writes of the pointee type.- The pointer must be valid for the full lifetime of this
SchemaRef
.
pub fn into_map(self) -> Result<&'pointer mut SchemaMap, SchemaRefMut<'pointer>>
pub fn into_map(self) -> Result<&'pointer mut SchemaMap, SchemaRefMut<'pointer>>
Borrow the schema ref as a SchemaMap
if it is one.
pub fn into_vec(self) -> Result<&'pointer mut SchemaVec, SchemaRefMut<'pointer>>
pub fn into_vec(self) -> Result<&'pointer mut SchemaVec, SchemaRefMut<'pointer>>
Borrow the schema ref as a SchemaVec
if it is one.
pub fn into_box(self) -> Result<SchemaRefMut<'pointer>, SchemaRefMut<'pointer>>
pub fn into_box(self) -> Result<SchemaRefMut<'pointer>, SchemaRefMut<'pointer>>
Borrow the schema ref as a SchemaBox
if it is one.
pub fn into_access_mut(self) -> SchemaRefMutAccess<'pointer>
pub fn into_access_mut(self) -> SchemaRefMutAccess<'pointer>
Convert into an accessor for the inner data.
pub fn access_mut(&mut self) -> SchemaRefMutAccess<'_>
pub fn access_mut(&mut self) -> SchemaRefMutAccess<'_>
Get a mutable access helper to this reference.
pub fn schema(&self) -> &'static Schema
pub fn schema(&self) -> &'static Schema
Get the [Schema
] for the pointer.
pub fn as_ref(&self) -> SchemaRef<'_>
pub fn as_ref(&self) -> SchemaRef<'_>
Borrow this SchemaRefMut
as a SchemaRef
.
pub fn reborrow(&mut self) -> SchemaRefMut<'_>
pub fn reborrow(&mut self) -> SchemaRefMut<'_>
Convert a borrowed SchemaRefMut
to an owned SchemaRefMut
with a lifetime matching
That of the borrow.
pub fn field<'a, I>(&mut self, field_idx: I) -> Option<SchemaRefMut<'_>>
pub fn field<'a, I>(&mut self, field_idx: I) -> Option<SchemaRefMut<'_>>
Get the reference to a field.
pub fn field_path<'a, I>(&mut self, path: I) -> Option<SchemaRefMut<'_>>where
I: IntoIterator<Item = FieldIdx<'a>>,
pub fn field_path<'a, I>(&mut self, path: I) -> Option<SchemaRefMut<'_>>where
I: IntoIterator<Item = FieldIdx<'a>>,
Get the field pointed to by the given path.
pub fn into_field_path<'a, I>(self, path: I) -> Option<SchemaRefMut<'pointer>>where
I: IntoIterator<Item = FieldIdx<'a>>,
pub fn into_field_path<'a, I>(self, path: I) -> Option<SchemaRefMut<'pointer>>where
I: IntoIterator<Item = FieldIdx<'a>>,
Get the field pointed to by the given path.
pub fn into_field<'a, I>(
self,
field_idx: I,
) -> Result<SchemaRefMut<'pointer>, SchemaRefMut<'pointer>>
pub fn into_field<'a, I>( self, field_idx: I, ) -> Result<SchemaRefMut<'pointer>, SchemaRefMut<'pointer>>
Get the reference to a field.
pub fn write(&mut self, other: SchemaRef<'_>) -> Result<(), SchemaMismatchError>
pub fn write(&mut self, other: SchemaRef<'_>) -> Result<(), SchemaMismatchError>
Clone other
and write it’s data to self
. Panics if this schema doesn’t support cloning.
Trait Implementations§
§impl<'pointer> Debug for SchemaRefMut<'pointer>
impl<'pointer> Debug for SchemaRefMut<'pointer>
§impl<'a, 'de> DeserializeSeed<'de> for SchemaRefMut<'a>
impl<'a, 'de> DeserializeSeed<'de> for SchemaRefMut<'a>
§fn deserialize<D>(
self,
deserializer: D,
) -> Result<<SchemaRefMut<'a> as DeserializeSeed<'de>>::Value, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
self,
deserializer: D,
) -> Result<<SchemaRefMut<'a> as DeserializeSeed<'de>>::Value, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize::deserialize
method, except
with some initial piece of data (the seed) passed in.