Struct bones_asset::SchemaBox
pub struct SchemaBox { /* private fields */ }
Expand description
A owning, type-erased Box
-like container for types with a [Schema
].
Implementations§
§impl SchemaBox
impl SchemaBox
pub fn cast_into<T>(self) -> Twhere
T: HasSchema,
pub fn cast_into<T>(self) -> Twhere T: HasSchema,
Cast this box to it’s inner type and return it.
Panics
Panics if the schema of the box does not match that of the type you are casting to.
pub fn try_cast_into<T>(self) -> Result<T, SchemaMismatchError>where
T: HasSchema,
pub fn try_cast_into<T>(self) -> Result<T, SchemaMismatchError>where T: HasSchema,
Cast this box to it’s inner type and return it.
Errors
Errors if the schema of the box does not match that of the type you are casting to.
pub unsafe fn cast_into_unchecked<T>(self) -> Twhere
T: HasSchema,
pub unsafe fn cast_into_unchecked<T>(self) -> Twhere T: HasSchema,
pub fn cast_ref<T>(&self) -> &Twhere
T: HasSchema,
pub fn cast_ref<T>(&self) -> &Twhere T: HasSchema,
Cast this box to a reference to a type with a representative [Schema
].
Panics
Panics if the schema of the box does not match that of the type you are casting to.
pub fn try_cast_ref<T>(&self) -> Result<&T, SchemaMismatchError>where
T: HasSchema,
pub fn try_cast_ref<T>(&self) -> Result<&T, SchemaMismatchError>where T: HasSchema,
Cast this box to a reference to a type with a representative [Schema
].
Errors
Errors if the schema of the box does not match that of the type you are casting to.
pub fn cast_mut<T>(&mut self) -> &mut Twhere
T: HasSchema,
pub fn cast_mut<T>(&mut self) -> &mut Twhere T: HasSchema,
Cast this box to a mutable reference to a type with a representing [Schema
].
Panics
Panics if the schema of the box 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 box to a mutable reference to a type with a representing [Schema
].
Errors
Errors if the schema of the box does not match that of the type you are casting to.
pub fn as_mut(&mut self) -> SchemaRefMut<'_>
pub fn as_mut(&mut self) -> SchemaRefMut<'_>
Borrow this box as a SchemaRefMut
.
pub fn new<T>(v: T) -> SchemaBoxwhere
T: HasSchema + Sync + Send,
pub fn new<T>(v: T) -> SchemaBoxwhere T: HasSchema + Sync + Send,
Create a new SchemaBox
from an owned type.
pub unsafe fn uninitialized(schema: &'static Schema) -> SchemaBox
pub unsafe fn uninitialized(schema: &'static Schema) -> SchemaBox
pub fn default(schema: &'static Schema) -> SchemaBox
pub fn default(schema: &'static Schema) -> SchemaBox
Create a new SchemaBox
for a type with a [Schema
] that has a
SchemaData::default_fn
.
Panics
Panics if the passed in schema doesn’t have a default_fn
.
pub fn try_into_sbox<T>(self) -> Result<SBox<T>, SchemaBox>where
T: HasSchema,
pub fn try_into_sbox<T>(self) -> Result<SBox<T>, SchemaBox>where T: HasSchema,
pub fn schema(&self) -> &'static Schema
pub fn schema(&self) -> &'static Schema
Get the [Schema
] for the pointer.
pub unsafe fn from_raw_parts(
ptr: NonNull<c_void>,
schema: &'static Schema
) -> SchemaBox
pub unsafe fn from_raw_parts( ptr: NonNull<c_void>, schema: &'static Schema ) -> SchemaBox
pub fn forget(self)
pub fn forget(self)
Deallocate the memory stored in the box, but don’t run the destructor.
Trait Implementations§
§impl HasSchema for SchemaBox
impl HasSchema for SchemaBox
§fn register_schema()
fn register_schema()
§fn cast<T>(this: &Self) -> &Twhere
T: HasSchema,
fn cast<T>(this: &Self) -> &Twhere T: HasSchema,
§fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>where
T: HasSchema,
fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>where T: HasSchema,
§fn cast_mut<T>(this: &mut Self) -> &mut Twhere
T: HasSchema,
fn cast_mut<T>(this: &mut Self) -> &mut Twhere T: HasSchema,
§fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>where
T: HasSchema,
fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>where T: HasSchema,
§fn as_schema_ref(&self) -> SchemaRef<'_>where
Self: Sized,
fn as_schema_ref(&self) -> SchemaRef<'_>where Self: Sized,
T
to a SchemaRef
§fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where
Self: Sized,
fn as_schema_mut(&mut self) -> SchemaRefMut<'_>where Self: Sized,
T
to a SchemaRefMut
impl Eq for SchemaBox
impl Send for SchemaBox
impl Sync for SchemaBox
Auto Trait Implementations§
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.