Struct bones_schema::ptr::SchemaRefMut
source · 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§
source§impl<'pointer> SchemaRefMut<'pointer>
impl<'pointer> SchemaRefMut<'pointer>
sourcepub 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()
.
sourcepub 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()
.
sourcepub fn try_cast_mut<T: HasSchema>(
&mut self,
) -> Result<&mut T, SchemaMismatchError>
pub fn try_cast_mut<T: HasSchema>( &mut self, ) -> Result<&mut T, SchemaMismatchError>
sourcepub fn cast_into_mut<T: HasSchema>(self) -> &'pointer mut T
pub fn cast_into_mut<T: HasSchema>(self) -> &'pointer mut T
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.
sourcepub fn try_cast_into_mut<T: HasSchema>(
self,
) -> Result<&'pointer mut T, SchemaMismatchError>
pub fn try_cast_into_mut<T: HasSchema>( self, ) -> Result<&'pointer mut T, SchemaMismatchError>
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.
sourcepub fn new<T: HasSchema>(v: &'pointer mut T) -> SchemaRefMut<'pointer>
pub fn new<T: HasSchema>(v: &'pointer mut T) -> SchemaRefMut<'pointer>
Create a new SchemaRefMut
from a reference to a type that implements HasSchema
.
sourcepub 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
.
sourcepub fn into_map(self) -> Result<&'pointer mut SchemaMap, Self>
pub fn into_map(self) -> Result<&'pointer mut SchemaMap, Self>
Borrow the schema ref as a SchemaMap
if it is one.
sourcepub fn into_vec(self) -> Result<&'pointer mut SchemaVec, Self>
pub fn into_vec(self) -> Result<&'pointer mut SchemaVec, Self>
Borrow the schema ref as a SchemaVec
if it is one.
sourcepub fn into_box(self) -> Result<SchemaRefMut<'pointer>, Self>
pub fn into_box(self) -> Result<SchemaRefMut<'pointer>, Self>
Borrow the schema ref as a SchemaBox
if it is one.
sourcepub fn into_access_mut(self) -> SchemaRefMutAccess<'pointer>
pub fn into_access_mut(self) -> SchemaRefMutAccess<'pointer>
Convert into an accessor for the inner data.
sourcepub fn access_mut(&mut self) -> SchemaRefMutAccess<'_>
pub fn access_mut(&mut self) -> SchemaRefMutAccess<'_>
Get a mutable access helper to this reference.
sourcepub fn as_ref(&self) -> SchemaRef<'_>
pub fn as_ref(&self) -> SchemaRef<'_>
Borrow this SchemaRefMut
as a SchemaRef
.
sourcepub 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.
sourcepub fn field<'a, I: Into<FieldIdx<'a>>>(
&mut self,
field_idx: I,
) -> Option<SchemaRefMut<'_>>
pub fn field<'a, I: Into<FieldIdx<'a>>>( &mut self, field_idx: I, ) -> Option<SchemaRefMut<'_>>
Get the reference to a field.
sourcepub fn field_path<'a, I: IntoIterator<Item = FieldIdx<'a>>>(
&mut self,
path: I,
) -> Option<SchemaRefMut<'_>>
pub fn field_path<'a, I: IntoIterator<Item = FieldIdx<'a>>>( &mut self, path: I, ) -> Option<SchemaRefMut<'_>>
Get the field pointed to by the given path.
sourcepub fn into_field_path<'a, I: IntoIterator<Item = FieldIdx<'a>>>(
self,
path: I,
) -> Option<Self>
pub fn into_field_path<'a, I: IntoIterator<Item = FieldIdx<'a>>>( self, path: I, ) -> Option<Self>
Get the field pointed to by the given path.
sourcepub fn into_field<'a, I: Into<FieldIdx<'a>>>(
self,
field_idx: I,
) -> Result<SchemaRefMut<'pointer>, Self>
pub fn into_field<'a, I: Into<FieldIdx<'a>>>( self, field_idx: I, ) -> Result<SchemaRefMut<'pointer>, Self>
Get the reference to a field.
Trait Implementations§
source§impl<'pointer> Debug for SchemaRefMut<'pointer>
impl<'pointer> Debug for SchemaRefMut<'pointer>
source§impl<'a, 'de> DeserializeSeed<'de> for SchemaRefMut<'a>
impl<'a, 'de> DeserializeSeed<'de> for SchemaRefMut<'a>
source§fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>where
D: Deserializer<'de>,
Deserialize::deserialize
method, except
with some initial piece of data (the seed) passed in.