Struct bones_schema::ptr::SBox
source · pub struct SBox<T: HasSchema> { /* private fields */ }
Expand description
A typed version of SchemaBox
.
This allows to use SBox<T>
extremely similar to a Box<T>
except that it can be converted
to and from a SchemaBox
for compatibility with the schema ecosystem.
Also, compared to a SchemaBox
, it is more efficient to access, because it avoids extra
runtime checks for a matching schema after it has been created, and doesn’t need to be cast to
T
upon every access.
Implementations§
Trait Implementations§
source§impl<T: HasSchema> HasSchema for SBox<T>
impl<T: HasSchema> HasSchema for SBox<T>
source§fn register_schema()
fn register_schema()
Register this schema with the global schema registry. Read more
source§fn cast<T: HasSchema>(this: &Self) -> &T
fn cast<T: HasSchema>(this: &Self) -> &T
Cast a reference of this type to a reference of another type with the same memory layout. Read more
source§fn try_cast<T: HasSchema>(this: &Self) -> Result<&T, SchemaMismatchError>
fn try_cast<T: HasSchema>(this: &Self) -> Result<&T, SchemaMismatchError>
Cast a reference of this type to a reference of another type with the same memory layout. Read more
source§fn cast_mut<T: HasSchema>(this: &mut Self) -> &mut T
fn cast_mut<T: HasSchema>(this: &mut Self) -> &mut T
Cast a mutable reference of this type to a reference of another type with the same memory
layout. Read more
source§fn try_cast_mut<T: HasSchema>(
this: &mut Self,
) -> Result<&mut T, SchemaMismatchError>
fn try_cast_mut<T: HasSchema>( this: &mut Self, ) -> Result<&mut T, SchemaMismatchError>
Cast a mutable reference of this type to a reference of another type with the same memory
layout. Read more
source§fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
Converts a reference of
T
to a SchemaRef
source§fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
Converts a reference of
T
to a SchemaRefMut
Auto Trait Implementations§
impl<T> Freeze for SBox<T>
impl<T> !RefUnwindSafe for SBox<T>
impl<T> Send for SBox<T>
impl<T> Sync for SBox<T>
impl<T> Unpin for SBox<T>where
T: Unpin,
impl<T> !UnwindSafe for SBox<T>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)