Trait bones_framework::asset::prelude::HasSchema

source ·
pub unsafe trait HasSchema: Sync + Send + 'static {
    // Required method
    fn schema() -> &'static Schema;

    // Provided methods
    fn register_schema() { ... }
    fn cast<T>(this: &Self) -> &T
       where T: HasSchema { ... }
    fn try_cast<T>(this: &Self) -> Result<&T, SchemaMismatchError>
       where T: HasSchema { ... }
    fn cast_mut<T>(this: &mut Self) -> &mut T
       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_mut(&mut self) -> SchemaRefMut<'_>
       where Self: Sized { ... }
}
Expand description

Trait implemented for types that have a [Schema].

§Safety

This trait is unsafe to implement manually because it makes claims about the memory layout of a type that may be depended on in unsafe code, but it is safe to derive HasSchema on supported types.

If implemented manually, you must ensure that the schema accurately describes the memory layout of the type, or else accessing the type according to the schema would be unsound.

Required Methods§

source

fn schema() -> &'static Schema

Get this type’s [Schema].

Provided Methods§

source

fn register_schema()

Register this schema with the global schema registry.

This is automatically done by the framework in many cases, whenever schema() is called, but it may be necessary sometimes to manually register it.

source

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.

§Panics

Panics if the schema of T doesn’t match the schema of Self.

source

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.

§Errors

Errors if the schema of T doesn’t match the schema of Self.

source

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.

§Panics

Panics if the schema of T doesn’t match the schema of Self.

source

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.

§Errors

Errors if the schema of T doesn’t match the schema of Self.

source

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

Converts a reference of T to a SchemaRef

source

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

Converts a reference of T to a SchemaRefMut

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl HasSchema for bool

source§

fn schema() -> &'static Schema

source§

impl HasSchema for f32

source§

fn schema() -> &'static Schema

source§

impl HasSchema for f64

source§

fn schema() -> &'static Schema

source§

impl HasSchema for i8

source§

fn schema() -> &'static Schema

source§

impl HasSchema for i16

source§

fn schema() -> &'static Schema

source§

impl HasSchema for i32

source§

fn schema() -> &'static Schema

source§

impl HasSchema for i64

source§

fn schema() -> &'static Schema

source§

impl HasSchema for i128

source§

fn schema() -> &'static Schema

source§

impl HasSchema for isize

source§

fn schema() -> &'static Schema

source§

impl HasSchema for u8

source§

fn schema() -> &'static Schema

source§

impl HasSchema for u16

source§

fn schema() -> &'static Schema

source§

impl HasSchema for u32

source§

fn schema() -> &'static Schema

source§

impl HasSchema for u64

source§

fn schema() -> &'static Schema

source§

impl HasSchema for u128

source§

fn schema() -> &'static Schema

source§

impl HasSchema for ()

source§

fn schema() -> &'static Schema

source§

impl HasSchema for usize

source§

fn schema() -> &'static Schema

source§

impl HasSchema for String

source§

fn schema() -> &'static Schema

Implementors§

source§

impl HasSchema for ButtonState

source§

impl HasSchema for GamepadAxis

source§

impl HasSchema for GamepadButton

source§

impl HasSchema for GamepadConnectionEventKind

source§

impl HasSchema for GamepadEvent

source§

impl HasSchema for GamepadRumbleRequest

source§

impl HasSchema for KeyCode

source§

impl HasSchema for SyncingInfo

source§

impl HasSchema for CameraSize

source§

impl HasSchema for Color

source§

impl HasSchema for Image

source§

impl HasSchema for AssetKind

source§

impl HasSchema for AnimatedSprite

source§

impl HasSchema for AnimationBankSprite

source§

impl HasSchema for AudioCenter

source§

impl HasSchema for AudioManager

source§

impl HasSchema for AudioSource

source§

impl HasSchema for Audio

source§

impl HasSchema for FrameDiagState

source§

impl HasSchema for BVec2

source§

impl HasSchema for BVec3

source§

impl HasSchema for BVec4

source§

impl HasSchema for DVec2

source§

impl HasSchema for DVec3

source§

impl HasSchema for DVec4

source§

impl HasSchema for IVec2

source§

impl HasSchema for IVec3

source§

impl HasSchema for IVec4

source§

impl HasSchema for Quat

source§

impl HasSchema for UVec2

source§

impl HasSchema for UVec3

source§

impl HasSchema for UVec4

source§

impl HasSchema for Vec2

source§

impl HasSchema for Vec3

source§

impl HasSchema for Vec4

source§

impl HasSchema for GamepadAxisEvent

source§

impl HasSchema for GamepadButtonEvent

source§

impl HasSchema for GamepadConnectionEvent

source§

impl HasSchema for GamepadInputs

source§

impl HasSchema for GamepadRumbleIntensity

source§

impl HasSchema for GamepadsRumble

source§

impl HasSchema for KeyboardEvent

source§

impl HasSchema for KeyboardInputs

source§

impl HasSchema for MouseInputs

source§

impl HasSchema for MouseScreenPosition

source§

impl HasSchema for MouseWorldPosition

source§

impl HasSchema for Window

source§

impl HasSchema for CommandQueue

source§

impl HasSchema for CurrentSystemStage

source§

impl HasSchema for Entities

source§

impl HasSchema for Entity

source§

impl HasSchema for Duration

source§

impl HasSchema for Ustr

source§

impl HasSchema for SessionOptions

source§

impl HasSchema for Sessions

source§

impl HasSchema for Time

source§

impl HasSchema for FluentBundleAsset

source§

impl HasSchema for FluentResourceAsset

source§

impl HasSchema for LocalizationAsset

source§

impl HasSchema for RootLocalizationFieldIdx

source§

impl HasSchema for LogFileGuard

source§

impl HasSchema for RngGenerator

source§

impl HasSchema for DisconnectedPlayers

source§

impl HasSchema for NetworkMatchSocket

source§

impl HasSchema for PlayerNetworkStats

source§

impl HasSchema for SchemaLuaEcsRefMetatable

source§

impl HasSchema for LuaEngine

source§

impl HasSchema for LuaPlugin

source§

impl HasSchema for LuaPlugins

source§

impl HasSchema for LuaScript

source§

impl HasSchema for Camera

source§

impl HasSchema for CameraShake

source§

impl HasSchema for CameraTraumaEvents

source§

impl HasSchema for ClearColor

source§

impl HasSchema for ShakeNoise

source§

impl HasSchema for Viewport

source§

impl HasSchema for Path2d

source§

impl HasSchema for Atlas

source§

impl HasSchema for AtlasCollisionTile

source§

impl HasSchema for AtlasSprite

source§

impl HasSchema for Sprite

source§

impl HasSchema for Tile

source§

impl HasSchema for TileLayer

source§

impl HasSchema for Transform

source§

impl HasSchema for EguiCtx

source§

impl HasSchema for EguiInputHook

source§

impl HasSchema for EguiSettings

source§

impl HasSchema for EguiTextures

source§

impl HasSchema for Font

source§

impl HasSchema for FontMeta

source§

impl HasSchema for BorderImageMeta

source§

impl HasSchema for ButtonBordersMeta

source§

impl HasSchema for ButtonThemeMeta

source§

impl HasSchema for MarginMeta

source§

impl HasSchema for Storage

source§

impl HasSchema for ExitBones

source§

impl HasSchema for Timer

source§

impl HasSchema for AssetServer

source§

impl HasSchema for SchemaAssetHandle

source§

impl HasSchema for SchemaBox

source§

impl HasSchema for SchemaDeserialize

source§

impl HasSchema for SchemaMetaAssetLoader

source§

impl HasSchema for UntypedHandle

source§

impl<K, V> HasSchema for SMap<K, V>
where K: HasSchema, V: HasSchema,

source§

impl<T> HasSchema for Maybe<T>
where T: HasSchema + Clone,

source§

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

source§

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

source§

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