Trait TupleStruct

Source
pub trait TupleStruct: PartialReflect {
    // Required methods
    fn field(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>;
    fn field_mut(
        &mut self,
        index: usize,
    ) -> Option<&mut (dyn PartialReflect + 'static)>;
    fn field_len(&self) -> usize;
    fn iter_fields(&self) -> TupleStructFieldIter<'_> ;

    // Provided methods
    fn clone_dynamic(&self) -> DynamicTupleStruct { ... }
    fn to_dynamic_tuple_struct(&self) -> DynamicTupleStruct { ... }
    fn get_represented_tuple_struct_info(
        &self,
    ) -> Option<&'static TupleStructInfo> { ... }
}
Expand description

A trait used to power tuple struct-like operations via reflection.

This trait uses the Reflect trait to allow implementors to have their fields be dynamically addressed by index.

When using #[derive(Reflect)] on a tuple struct, this trait will be automatically implemented.

§Example

use bevy_reflect::{PartialReflect, Reflect, TupleStruct};

#[derive(Reflect)]
struct Foo(u32);

let foo = Foo(123);

assert_eq!(foo.field_len(), 1);

let field: &dyn PartialReflect = foo.field(0).unwrap();
assert_eq!(field.try_downcast_ref::<u32>(), Some(&123));

Required Methods§

Source

fn field(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>

Returns a reference to the value of the field with index index as a &dyn Reflect.

Source

fn field_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>

Returns a mutable reference to the value of the field with index index as a &mut dyn Reflect.

Source

fn field_len(&self) -> usize

Returns the number of fields in the tuple struct.

Source

fn iter_fields(&self) -> TupleStructFieldIter<'_>

Returns an iterator over the values of the tuple struct’s fields.

Provided Methods§

Source

fn clone_dynamic(&self) -> DynamicTupleStruct

👎Deprecated since 0.16.0: use to_dynamic_tuple_struct instead

Clones the struct into a DynamicTupleStruct.

Source

fn to_dynamic_tuple_struct(&self) -> DynamicTupleStruct

Creates a new DynamicTupleStruct from this tuple struct.

Source

fn get_represented_tuple_struct_info(&self) -> Option<&'static TupleStructInfo>

Will return None if TypeInfo is not available.

Trait Implementations§

Source§

impl GetTupleStructField for dyn TupleStruct

Source§

fn get_field<T>(&self, index: usize) -> Option<&T>
where T: Reflect,

Returns a reference to the value of the field with index index, downcast to T.
Source§

fn get_field_mut<T>(&mut self, index: usize) -> Option<&mut T>
where T: Reflect,

Returns a mutable reference to the value of the field with index index, downcast to T.

Implementations on Foreign Types§

Source§

impl TupleStruct for InputFocus
where InputFocus: Any + Send + Sync, Option<Entity>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn field(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>

Source§

fn field_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleStructFieldIter<'_>

Source§

fn to_dynamic_tuple_struct(&self) -> DynamicTupleStruct

Source§

impl TupleStruct for InputFocusVisible
where InputFocusVisible: Any + Send + Sync, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn field(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>

Source§

fn field_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleStructFieldIter<'_>

Source§

fn to_dynamic_tuple_struct(&self) -> DynamicTupleStruct

Source§

impl TupleStruct for TabIndex
where TabIndex: Any + Send + Sync, i32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn field(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>

Source§

fn field_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>

Source§

fn field_len(&self) -> usize

Source§

fn iter_fields(&self) -> TupleStructFieldIter<'_>

Source§

fn to_dynamic_tuple_struct(&self) -> DynamicTupleStruct

Implementors§

Source§

impl TupleStruct for AccessibilityRequested
where AccessibilityRequested: Any + Send + Sync, Arc<AtomicBool>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for ManageAccessibilityUpdates
where ManageAccessibilityUpdates: Any + Send + Sync, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for DenoiseCas
where DenoiseCas: Any + Send + Sync, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for Camera3dDepthTextureUsage
where Camera3dDepthTextureUsage: Any + Send + Sync, u32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for ComponentId
where ComponentId: Any + Send + Sync, usize: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for EntityHashSet
where EntityHashSet: Any + Send + Sync, HashSet<Entity, EntityHash>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for RemovedComponentEntity
where RemovedComponentEntity: Any + Send + Sync, Entity: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for PanGesture
where PanGesture: Any + Send + Sync, Vec2: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for PinchGesture
where PinchGesture: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for RotationGesture
where RotationGesture: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for AspectRatio
where AspectRatio: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for FloatOrd
where FloatOrd: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for DefaultOpaqueRendererMethod
where DefaultOpaqueRendererMethod: Any + Send + Sync, OpaqueRendererMethod: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for MaterialBindGroupIndex
where MaterialBindGroupIndex: Any + Send + Sync, u32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for MaterialBindGroupSlot
where MaterialBindGroupSlot: Any + Send + Sync, u32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for Mesh3dWireframe
where Mesh3dWireframe: Any + Send + Sync, Handle<WireframeMaterial>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for DynamicTupleStruct

Source§

impl TupleStruct for ManualTextureViewHandle
where ManualTextureViewHandle: Any + Send + Sync, u32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for MipBias
where MipBias: Any + Send + Sync, f32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for ReadbackComplete
where ReadbackComplete: Any + Send + Sync, Vec<u8>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for MeshTag
where MeshTag: Any + Send + Sync, u32: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for RenderLayers
where RenderLayers: Any + Send + Sync, SmallVec<[u64; 1]>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for VisibilityClass
where VisibilityClass: Any + Send + Sync, SmallVec<[TypeId; 1]>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for Screenshot
where Screenshot: Any + Send + Sync, RenderTarget: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for ScreenshotCaptured
where ScreenshotCaptured: Any + Send + Sync, Image: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for NormalizedWindowRef
where NormalizedWindowRef: Any + Send + Sync, Entity: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for ChildOf
where ChildOf: Any + Send + Sync, Entity: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for Children
where Children: Any + Send + Sync, Vec<Entity>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for ClearColor
where ClearColor: Any + Send + Sync, Color: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for Dir2
where Dir2: Any + Send + Sync, Vec2: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for Dir3
where Dir3: Any + Send + Sync, Vec3: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for Dir3A
where Dir3A: Any + Send + Sync, Vec3A: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for GlobalTransform
where GlobalTransform: Any + Send + Sync, Affine3A: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for InheritedVisibility
where InheritedVisibility: Any + Send + Sync, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for Mesh2d
where Mesh2d: Any + Send + Sync, Handle<Mesh>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for Mesh3d
where Mesh3d: Any + Send + Sync, Handle<Mesh>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl TupleStruct for ViewVisibility
where ViewVisibility: Any + Send + Sync, bool: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl<C> TupleStruct for SampleDerivativeWrapper<C>
where SampleDerivativeWrapper<C>: Any + Send + Sync, C: TypePath + PartialReflect + MaybeTyped + RegisterForReflection,

Source§

impl<C> TupleStruct for SampleTwoDerivativesWrapper<C>
where SampleTwoDerivativesWrapper<C>: Any + Send + Sync, C: TypePath + PartialReflect + MaybeTyped + RegisterForReflection,

Source§

impl<M> TupleStruct for MeshMaterial3d<M>
where M: Material + TypePath, MeshMaterial3d<M>: Any + Send + Sync, Handle<M>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl<V> TupleStruct for EntityHashMap<V>
where EntityHashMap<V>: Any + Send + Sync, V: TypePath, HashMap<Entity, V, EntityHash>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl<V> TupleStruct for EntityIndexMap<V>
where EntityIndexMap<V>: Any + Send + Sync, V: TypePath, IndexMap<Entity, V, EntityHash>: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

impl<V, W> TupleStruct for Sum<V, W>
where Sum<V, W>: Any + Send + Sync, V: TypePath + FromReflect + MaybeTyped + RegisterForReflection, W: TypePath + FromReflect + MaybeTyped + RegisterForReflection,