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>

source

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().

source

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().

source

pub fn cast_mut<T: HasSchema + 'static>(&mut self) -> &mut T

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.

source

pub fn try_cast_mut<T: HasSchema>( &mut self, ) -> Result<&mut T, SchemaMismatchError>

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.

source

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.

source

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.

source

pub fn new<T: HasSchema>(v: &'pointer mut T) -> SchemaRefMut<'pointer>

Create a new SchemaRefMut from a reference to a type that implements HasSchema.

source

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 given schema.
  • 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.
source

pub fn into_map(self) -> Result<&'pointer mut SchemaMap, Self>

Borrow the schema ref as a SchemaMap if it is one.

source

pub fn into_vec(self) -> Result<&'pointer mut SchemaVec, Self>

Borrow the schema ref as a SchemaVec if it is one.

source

pub fn into_box(self) -> Result<SchemaRefMut<'pointer>, Self>

Borrow the schema ref as a SchemaBox if it is one.

source

pub fn into_access_mut(self) -> SchemaRefMutAccess<'pointer>

Convert into an accessor for the inner data.

source

pub fn access_mut(&mut self) -> SchemaRefMutAccess<'_>

Get a mutable access helper to this reference.

source

pub fn as_ptr(&self) -> *mut c_void

Get the raw pointer

source

pub fn schema(&self) -> &'static Schema

Get the Schema for the pointer.

source

pub fn hash(&self) -> Option<u64>

Get the hash of this schema box, if supported.

source

pub fn as_ref(&self) -> SchemaRef<'_>

Borrow this SchemaRefMut as a SchemaRef.

source

pub fn reborrow(&mut self) -> SchemaRefMut<'_>

Convert a borrowed SchemaRefMut to an owned SchemaRefMut with a lifetime matching That of the borrow.

source

pub fn field<'a, I: Into<FieldIdx<'a>>>( &mut self, field_idx: I, ) -> Option<SchemaRefMut<'_>>

Get the reference to a field.

source

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.

source

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.

source

pub fn into_field<'a, I: Into<FieldIdx<'a>>>( self, field_idx: I, ) -> Result<SchemaRefMut<'pointer>, Self>

Get the reference to a field.

source

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§

source§

impl<'pointer> Debug for SchemaRefMut<'pointer>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a, 'de> DeserializeSeed<'de> for SchemaRefMut<'a>

§

type Value = ()

The type produced by using this seed.
source§

fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
where D: Deserializer<'de>,

Equivalent to the more common Deserialize::deserialize method, except with some initial piece of data (the seed) passed in.
source§

impl<'a> From<SchemaRefMut<'a>> for PrimitiveRefMut<'a>

source§

fn from(value: SchemaRefMut<'a>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'pointer> Freeze for SchemaRefMut<'pointer>

§

impl<'pointer> !RefUnwindSafe for SchemaRefMut<'pointer>

§

impl<'pointer> !Send for SchemaRefMut<'pointer>

§

impl<'pointer> !Sync for SchemaRefMut<'pointer>

§

impl<'pointer> Unpin for SchemaRefMut<'pointer>

§

impl<'pointer> !UnwindSafe for SchemaRefMut<'pointer>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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> RawDrop for T

source§

unsafe fn raw_drop(ptr: *mut c_void)

Write the default value of the type to the pointer. Read more
source§

fn raw_drop_cb() -> Unsafe<&'static (dyn Fn(*mut c_void) + Sync + Send + 'static)>

Get a callback suitable for SchemaData.
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V