Struct bones_lib::prelude::bones_schema::ptr::SBox

pub struct SBox<T>
where 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§

§

impl<T> SBox<T>
where T: HasSchema,

pub fn new(value: T) -> SBox<T>

Create a new SBox.

pub fn into_schema_box(self) -> SchemaBox

Convert into a SchemaBox

Trait Implementations§

§

impl<T> Clone for SBox<T>
where T: HasSchema,

§

fn clone(&self) -> SBox<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Debug for SBox<T>
where T: HasSchema + Debug,

§

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

Formats the value using the given formatter. Read more
§

impl<T> Default for SBox<T>
where T: HasSchema,

§

fn default() -> SBox<T>

Returns the “default value” for a type. Read more
§

impl<T> Deref for SBox<T>
where T: HasSchema,

§

type Target = T

The resulting type after dereferencing.
§

fn deref(&self) -> &<SBox<T> as Deref>::Target

Dereferences the value.
§

impl<T> DerefMut for SBox<T>
where T: HasSchema,

§

fn deref_mut(&mut self) -> &mut <SBox<T> as Deref>::Target

Mutably dereferences the value.
§

impl<T> From<SBox<T>> for SchemaBox
where T: HasSchema,

§

fn from(value: SBox<T>) -> SchemaBox

Converts to this type from the input type.
§

impl<T> HasSchema for SBox<T>
where T: HasSchema,

§

fn schema() -> &'static Schema

Get this type’s [Schema].
§

fn register_schema()

Register this schema with the global schema registry. Read more
§

fn cast<T>(this: &Self) -> &T
where T: HasSchema,

Cast a reference of this type to a reference of another type with the same memory layout. Read more
§

fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>
where T: HasSchema,

Cast a reference of this type to a reference of another type with the same memory layout. Read more
§

fn cast_mut<T>(this: &mut Self) -> &mut T
where T: HasSchema,

Cast a mutable reference of this type to a reference of another type with the same memory layout. Read more
§

fn try_cast_mut<T>(this: &mut Self) -> Result<&mut T, SchemaMismatchError>
where T: HasSchema,

Cast a mutable reference of this type to a reference of another type with the same memory layout. Read more
§

fn as_schema_ref(&self) -> SchemaRef<'_>
where Self: Sized,

Converts a reference of T to a SchemaRef
§

fn as_schema_mut(&mut self) -> SchemaRefMut<'_>
where Self: Sized,

Converts a reference of T to a SchemaRefMut
§

impl<T> TryFrom<SchemaBox> for SBox<T>
where T: HasSchema,

§

type Error = SchemaBox

The type returned in the event of a conversion error.
§

fn try_from( value: SchemaBox, ) -> Result<SBox<T>, <SBox<T> as TryFrom<SchemaBox>>::Error>

Performs the conversion.

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> 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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromWorld for T
where T: Default,

§

fn from_world(_world: &World) -> T

Creates Self using data from the given World.
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.

§

impl<T> RawClone for T
where T: Clone,

§

unsafe fn raw_clone(src: *const c_void, dst: *mut c_void)

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

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

Get a callback suitable for [SchemaData].
§

impl<T> RawDefault for T
where T: Default,

§

unsafe fn raw_default(dst: *mut c_void)

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

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

Get a callback suitable for [SchemaData].
§

impl<T> RawDrop for T

§

unsafe fn raw_drop(ptr: *mut c_void)

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

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

Get a callback suitable for [SchemaData].
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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