Struct bones_asset::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 SchemaBoxwhere 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) -> &Twhere 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 Twhere 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> !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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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 Twhere 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 Twhere 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more