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,
Unsafely convert this box into an owned T.
§Safety
- The schema of type T must equal that of this box.
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 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§
impl Freeze for SchemaBox
impl !RefUnwindSafe for SchemaBox
impl Unpin for SchemaBox
impl !UnwindSafe for SchemaBox
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
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)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &World) -> T
fn from_world(_world: &World) -> T
Self
using data from the given World
.