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

pub fn as_ptr(&self) -> *mut c_void

Get a raw pointer to the box data.

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,

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,

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,

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,

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,

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,

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_ref(&self) -> SchemaRef<'_>

Borrow this box as a SchemaRef.

pub fn as_mut(&mut self) -> SchemaRefMut<'_>

Borrow this box as a SchemaRefMut.

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

Allocates a SchemaBox for the given [Schema], but doesn’t initialize the memory.

Safety

Accessing the data in an unitinialized SchemaBox is undefined behavior. It is up to the user to initialize the memory pointed at by the box after creating it.

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 into_sbox<T>(self) -> SBox<T>where T: HasSchema,

Convert into an SBox if the schema of T matches.

Panics

Panics if the schema of T doesn’t match that of the box.

pub fn try_into_sbox<T>(self) -> Result<SBox<T>, SchemaBox>where T: HasSchema,

Convert into an SBox if the schema of T matches.

Errors

Returns an error with the orignal SchemaBox if the schema of T doesn’t match.

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

Create a new SchemaBox from raw parts.

This is useful for creating a SchemaBox for data with a schema loaded at runtime and without a Rust type.

Safety
  • You must insure that the pointer is valid for the given schema.

pub fn forget(self)

Deallocate the memory stored in the box, but don’t run the destructor.

pub fn try_hash(&self) -> Option<u64>

Get the hash of this schema box, if supported.

pub fn hash(&self) -> u64

Get the hash of this schema box.

Panics

Panics if the schema doesn’t implement hash.

Trait Implementations§

§

impl Clone for SchemaBox

§

fn clone(&self) -> SchemaBox

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 Debug for SchemaBox

§

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

Formats the value using the given formatter. Read more
§

impl Default for SchemaBox

§

fn default() -> SchemaBox

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

impl Display for SchemaBox

§

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

Formats the value using the given formatter. Read more
§

impl Drop for SchemaBox

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl<T> From<SBox<T>> for SchemaBoxwhere T: HasSchema,

§

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

Converts to this type from the input type.
§

impl HasSchema for SchemaBox

§

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 Hash for SchemaBox

§

fn hash<H>(&self, state: &mut H)where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for SchemaBox

§

fn eq(&self, other: &SchemaBox) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

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.
§

impl Eq for SchemaBox

§

impl Send for SchemaBox

§

impl Sync for SchemaBox

Auto Trait Implementations§

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
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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].
§

impl<T> RawEq for Twhere T: Eq,

§

unsafe fn raw_eq(a: *const c_void, b: *const c_void) -> bool

Get the hash of the type. Read more
§

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

Get a callback suitable for [SchemaData].
§

impl<T> RawHash for Twhere T: Hash,

§

unsafe fn raw_hash(ptr: *const c_void) -> u64

Get the hash of the type. Read more
§

fn raw_hash_cb( ) -> Unsafe<&'static (dyn Fn(*const c_void) -> u64 + 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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