pub trait TypePath: 'static {
// Required methods
fn type_path() -> &'static str;
fn short_type_path() -> &'static str;
// Provided methods
fn type_ident() -> Option<&'static str> { ... }
fn crate_name() -> Option<&'static str> { ... }
fn module_path() -> Option<&'static str> { ... }
}
Expand description
A static accessor to type paths and names.
The engine uses this trait over std::any::type_name
for stability and flexibility.
This trait is automatically implemented by the #[derive(Reflect)]
macro
and allows type path information to be processed without an instance of that type.
Implementors may have difficulty in generating references with static lifetimes. Luckily, this crate comes with some utility structs, to make generating these statics much simpler.
§Stability
Certain parts of the engine, e.g. (de)serialization, rely on type paths as identifiers for matching dynamic values to concrete types.
Using std::any::type_name
, a scene containing my_crate::foo::MyComponent
would break,
failing to deserialize if the component was moved from the foo
module to the bar
module,
becoming my_crate::bar::MyComponent
.
This trait, through attributes when deriving itself or Reflect
, can ensure breaking changes are avoidable.
The only external factor we rely on for stability when deriving is the module_path!
macro,
only if the derive does not provide a #[type_path = "..."]
attribute.
§Anonymity
Some methods on this trait return Option<&'static str>
over &'static str
because not all types define all parts of a type path, for example the array type [T; N]
.
Such types are ‘anonymous’ in that they have only a defined type_path
and short_type_path
and the methods crate_name
, module_path
and type_ident
all return None
.
Primitives are treated like anonymous types, except they also have a defined type_ident
.
§Example
use bevy_reflect::TypePath;
// This type path will not change with compiler versions or recompiles,
// although it will not be the same if the definition is moved.
#[derive(TypePath)]
struct NonStableTypePath;
// This type path will never change, even if the definition is moved.
#[derive(TypePath)]
#[type_path = "my_crate::foo"]
struct StableTypePath;
// Type paths can have any number of path segments.
#[derive(TypePath)]
#[type_path = "my_crate::foo::bar::baz"]
struct DeeplyNestedStableTypePath;
// Including just a crate name!
#[derive(TypePath)]
#[type_path = "my_crate"]
struct ShallowStableTypePath;
// We can also rename the identifier/name of types.
#[derive(TypePath)]
#[type_path = "my_crate::foo"]
#[type_name = "RenamedStableTypePath"]
struct NamedStableTypePath;
// Generics are also supported.
#[derive(TypePath)]
#[type_path = "my_crate::foo"]
struct StableGenericTypePath<T, const N: usize>([T; N]);
Required Methods§
Sourcefn type_path() -> &'static str
fn type_path() -> &'static str
Returns the fully qualified path of the underlying type.
Generic parameter types are also fully expanded.
For Option<Vec<usize>>
, this is "std::option::Option<std::vec::Vec<usize>>"
.
Sourcefn short_type_path() -> &'static str
fn short_type_path() -> &'static str
Returns a short, pretty-print enabled path to the type.
Generic parameter types are also shortened.
For Option<Vec<usize>>
, this is "Option<Vec<usize>>"
.
Provided Methods§
Sourcefn type_ident() -> Option<&'static str>
fn type_ident() -> Option<&'static str>
Sourcefn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl TypePath for BuildHasherDefault<AHasher>
impl TypePath for BuildHasherDefault<AHasher>
Source§impl TypePath for AtomicBool
impl TypePath for AtomicBool
Source§impl TypePath for AtomicIsize
impl TypePath for AtomicIsize
Source§impl TypePath for AtomicUsize
impl TypePath for AtomicUsize
Source§impl TypePath for RandomState
impl TypePath for RandomState
Source§impl<P1, P2, P0> TypePath for (P1, P2, P0)
impl<P1, P2, P0> TypePath for (P1, P2, P0)
Source§impl<P1, P2, P3, P0> TypePath for (P1, P2, P3, P0)
impl<P1, P2, P3, P0> TypePath for (P1, P2, P3, P0)
Source§impl<P1, P2, P3, P4, P0> TypePath for (P1, P2, P3, P4, P0)
impl<P1, P2, P3, P4, P0> TypePath for (P1, P2, P3, P4, P0)
Source§impl<P1, P2, P3, P4, P5, P0> TypePath for (P1, P2, P3, P4, P5, P0)
impl<P1, P2, P3, P4, P5, P0> TypePath for (P1, P2, P3, P4, P5, P0)
Source§impl<P1, P2, P3, P4, P5, P6, P0> TypePath for (P1, P2, P3, P4, P5, P6, P0)
impl<P1, P2, P3, P4, P5, P6, P0> TypePath for (P1, P2, P3, P4, P5, P6, P0)
Source§impl<P1, P2, P3, P4, P5, P6, P7, P0> TypePath for (P1, P2, P3, P4, P5, P6, P7, P0)
impl<P1, P2, P3, P4, P5, P6, P7, P0> TypePath for (P1, P2, P3, P4, P5, P6, P7, P0)
Source§impl<P1, P2, P3, P4, P5, P6, P7, P8, P0> TypePath for (P1, P2, P3, P4, P5, P6, P7, P8, P0)
impl<P1, P2, P3, P4, P5, P6, P7, P8, P0> TypePath for (P1, P2, P3, P4, P5, P6, P7, P8, P0)
Source§impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P0> TypePath for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P0)
impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P0> TypePath for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P0)
Source§impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P0> TypePath for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P0)
impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P0> TypePath for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P0)
Source§impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P0> TypePath for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P0)
impl<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P0> TypePath for (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P0)
Source§impl<T> TypePath for &'static T
impl<T> TypePath for &'static T
Source§impl<T> TypePath for &'static mut T
impl<T> TypePath for &'static mut T
Source§impl<T> TypePath for BinaryHeap<T>
impl<T> TypePath for BinaryHeap<T>
Source§impl<T> TypePath for Saturating<T>
impl<T> TypePath for Saturating<T>
Source§impl<T> TypePath for RangeInclusive<T>
impl<T> TypePath for RangeInclusive<T>
Source§impl<T> TypePath for RangeToInclusive<T>
impl<T> TypePath for RangeToInclusive<T>
Implementors§
impl TypePath for BloomCompositeMode
impl TypePath for Camera3dDepthLoadOp
impl TypePath for ScreenSpaceTransmissionQuality
impl TypePath for DepthOfFieldMode
impl TypePath for Sensitivity
impl TypePath for SmaaPreset
impl TypePath for DebandDither
impl TypePath for Tonemapping
impl TypePath for HierarchyEvent
impl TypePath for ButtonState
impl TypePath for GamepadConnection
impl TypePath for GamepadEvent
impl TypePath for GamepadInput
impl TypePath for GamepadRumbleRequest
impl TypePath for RawGamepadEvent
impl TypePath for Key
impl TypePath for NativeKey
impl TypePath for NativeKeyCode
impl TypePath for MouseScrollUnit
impl TypePath for ForceTouch
impl TypePath for TouchPhase
impl TypePath for CompassOctant
impl TypePath for CompassQuadrant
impl TypePath for ClusterConfig
impl TypePath for ClusterFarZMode
impl TypePath for OpaqueRendererMethod
impl TypePath for ScreenSpaceAmbientOcclusionQualityLevel
impl TypePath for ShadowFilteringMethod
impl TypePath for UvChannel
impl TypePath for PickingInteraction
impl TypePath for PointerAction
impl TypePath for PointerId
impl TypePath for PressDirection
impl TypePath for AlphaMode
impl TypePath for ClearColorConfig
impl TypePath for Color
impl TypePath for EaseFunction
impl TypePath for EulerRot
impl TypePath for FileDragAndDrop
impl TypePath for FogFalloff
impl TypePath for GamepadAxis
impl TypePath for GamepadButton
impl TypePath for Ime
impl TypePath for KeyCode
impl TypePath for MonitorSelection
impl TypePath for MouseButton
impl TypePath for Msaa
impl TypePath for ParallaxMappingMethod
impl TypePath for PointerButton
impl TypePath for Projection
impl TypePath for TimerMode
impl TypePath for Visibility
impl TypePath for WindowPosition
impl TypePath for NormalizedRenderTarget
impl TypePath for RenderTarget
impl TypePath for ScalingMode
impl TypePath for Indices
impl TypePath for AppLifecycle
impl TypePath for CompositeAlphaMode
impl TypePath for CursorGrabMode
impl TypePath for PresentMode
impl TypePath for SystemCursorIcon
impl TypePath for WindowEvent
impl TypePath for WindowLevel
impl TypePath for WindowMode
impl TypePath for WindowRef
impl TypePath for WindowTheme
impl TypePath for CursorIcon
impl TypePath for CustomCursor
impl TypePath for Focus
impl TypePath for AssetIndex
impl TypePath for LoadedFolder
impl TypePath for LoadedUntypedAsset
impl TypePath for RenderAssetUsages
impl TypePath for StrongHandle
impl TypePath for AutoExposure
impl TypePath for AutoExposureCompensationCurve
impl TypePath for Bloom
impl TypePath for BloomPrefilter
impl TypePath for ContrastAdaptiveSharpening
impl TypePath for DenoiseCas
impl TypePath for Camera3dDepthTextureUsage
impl TypePath for DepthOfField
impl TypePath for TemporalAntiAliasing
impl TypePath for Fxaa
impl TypePath for MotionBlur
impl TypePath for OrderIndependentTransparencySettings
impl TypePath for ChromaticAberration
impl TypePath for DeferredPrepass
impl TypePath for DepthPrepass
impl TypePath for MotionVectorPrepass
impl TypePath for NormalPrepass
impl TypePath for Smaa
impl TypePath for ComponentId
impl TypePath for ComponentTicks
impl TypePath for Tick
impl TypePath for EntityHash
impl TypePath for Identifier
impl TypePath for RemovedComponentEntity
impl TypePath for SystemIdMarker
impl TypePath for AxisSettings
impl TypePath for ButtonAxisSettings
impl TypePath for ButtonSettings
impl TypePath for GamepadAxisChangedEvent
impl TypePath for GamepadButtonChangedEvent
impl TypePath for GamepadButtonStateChangedEvent
impl TypePath for GamepadConnectionEvent
impl TypePath for GamepadRumbleIntensity
impl TypePath for RawGamepadAxisChangedEvent
impl TypePath for RawGamepadButtonChangedEvent
impl TypePath for DoubleTapGesture
impl TypePath for PanGesture
impl TypePath for PinchGesture
impl TypePath for RotationGesture
impl TypePath for KeyboardFocusLost
impl TypePath for KeyboardInput
impl TypePath for AccumulatedMouseMotion
impl TypePath for AccumulatedMouseScroll
impl TypePath for MouseButtonInput
impl TypePath for MouseMotion
impl TypePath for MouseWheel
impl TypePath for Aabb2d
impl TypePath for Aabb3d
impl TypePath for AabbCast2d
impl TypePath for AabbCast3d
impl TypePath for BoundingCircle
impl TypePath for BoundingCircleCast
impl TypePath for BoundingSphere
impl TypePath for BoundingSphereCast
impl TypePath for RayCast2d
impl TypePath for RayCast3d
impl TypePath for Affine2
impl TypePath for Affine3
impl TypePath for Affine3A
impl TypePath for AspectRatio
impl TypePath for BVec3A
impl TypePath for BVec4A
impl TypePath for DAffine2
impl TypePath for DAffine3
impl TypePath for DMat2
impl TypePath for DMat3
impl TypePath for DMat4
impl TypePath for DQuat
impl TypePath for DVec2
impl TypePath for DVec3
impl TypePath for DVec4
impl TypePath for FloatOrd
impl TypePath for I64Vec2
impl TypePath for I64Vec3
impl TypePath for I64Vec4
impl TypePath for Mat3A
impl TypePath for U64Vec2
impl TypePath for U64Vec3
impl TypePath for U64Vec4
impl TypePath for Vec3A
impl TypePath for IrradianceVolume
impl TypePath for Cascade
impl TypePath for CascadeShadowConfig
impl TypePath for Cascades
impl TypePath for CascadesVisibleEntities
impl TypePath for ClusterZConfig
impl TypePath for CubemapVisibleEntities
impl TypePath for DefaultOpaqueRendererMethod
impl TypePath for DirectionalLightShadowMap
impl TypePath for FogVolume
impl TypePath for Lightmap
impl TypePath for NotShadowCaster
impl TypePath for NotShadowReceiver
impl TypePath for PointLightShadowMap
impl TypePath for RenderCascadesVisibleEntities
impl TypePath for RenderCubemapVisibleEntities
impl TypePath for RenderVisibleMeshEntities
impl TypePath for ScreenSpaceAmbientOcclusion
impl TypePath for ScreenSpaceReflections
impl TypePath for TransmittedShadowReceiver
impl TypePath for VisibleMeshEntities
impl TypePath for VolumetricFog
impl TypePath for VolumetricLight
impl TypePath for NoWireframe
impl TypePath for Wireframe
impl TypePath for WireframeColor
impl TypePath for WireframeConfig
impl TypePath for WireframeMaterial
impl TypePath for RayId
impl TypePath for HitData
impl TypePath for PointerHits
impl TypePath for Location
impl TypePath for PointerInput
impl TypePath for PointerInteraction
impl TypePath for PointerLocation
impl TypePath for PointerPress
impl TypePath for AmbientLight
impl TypePath for Annulus
impl TypePath for Arc2d
impl TypePath for BVec2
impl TypePath for BVec3
impl TypePath for BVec4
impl TypePath for Camera2d
impl TypePath for Camera3d
impl TypePath for Camera
impl TypePath for Cancel
impl TypePath for Capsule2d
impl TypePath for Capsule3d
impl TypePath for Children
impl TypePath for Circle
impl TypePath for CircularSector
impl TypePath for CircularSegment
impl TypePath for ClearColor
impl TypePath for Click
impl TypePath for Cone
impl TypePath for ConicalFrustum
impl TypePath for Cuboid
impl TypePath for CursorEntered
impl TypePath for CursorLeft
impl TypePath for CursorMoved
impl TypePath for Cylinder
impl TypePath for Dir2
impl TypePath for Dir3
impl TypePath for Dir3A
impl TypePath for DirectionalLight
impl TypePath for DistanceFog
impl TypePath for Down
impl TypePath for Drag
impl TypePath for DragDrop
impl TypePath for DragEnd
impl TypePath for DragEnter
impl TypePath for DragLeave
impl TypePath for DragOver
impl TypePath for DragStart
impl TypePath for Ellipse
impl TypePath for Entity
impl TypePath for EnvironmentMapLight
impl TypePath for Fixed
impl TypePath for Gamepad
impl TypePath for GamepadSettings
impl TypePath for GlobalTransform
impl TypePath for Hsla
impl TypePath for Hsva
impl TypePath for Hwba
impl TypePath for IRect
impl TypePath for IVec2
impl TypePath for IVec3
impl TypePath for IVec4
impl TypePath for Image
impl TypePath for InfinitePlane3d
impl TypePath for InheritedVisibility
impl TypePath for Interval
impl TypePath for Isometry2d
impl TypePath for Isometry3d
impl TypePath for Laba
impl TypePath for Lcha
impl TypePath for LightProbe
impl TypePath for Line2d
impl TypePath for Line3d
impl TypePath for LinearRgba
impl TypePath for Mat2
impl TypePath for Mat3
impl TypePath for Mat4
impl TypePath for Mesh2d
impl TypePath for Mesh3d
impl TypePath for Mesh
impl TypePath for MorphWeights
impl TypePath for Move
impl TypePath for Name
impl TypePath for Oklaba
impl TypePath for Oklcha
impl TypePath for OnAdd
impl TypePath for OnInsert
impl TypePath for OnRemove
impl TypePath for OnReplace
impl TypePath for OrthographicProjection
impl TypePath for Out
impl TypePath for Over
impl TypePath for Parent
impl TypePath for PerspectiveProjection
impl TypePath for PickingBehavior
impl TypePath for PickingPlugin
impl TypePath for Plane2d
impl TypePath for Plane3d
impl TypePath for PointLight
impl TypePath for PointerInputPlugin
impl TypePath for Quat
impl TypePath for Ray2d
impl TypePath for Ray3d
impl TypePath for Real
impl TypePath for Rect
impl TypePath for Rectangle
impl TypePath for RegularPolygon
impl TypePath for Rhombus
impl TypePath for Rot2
impl TypePath for Segment2d
impl TypePath for Segment3d
impl TypePath for Shader
impl TypePath for Sphere
impl TypePath for SpotLight
impl TypePath for Srgba
impl TypePath for StandardMaterial
impl TypePath for Tetrahedron
impl TypePath for Timer
impl TypePath for Torus
impl TypePath for TouchInput
impl TypePath for Transform
impl TypePath for Triangle2d
impl TypePath for Triangle3d
impl TypePath for URect
impl TypePath for UVec2
impl TypePath for UVec3
impl TypePath for UVec4
impl TypePath for Up
impl TypePath for Vec2
impl TypePath for Vec3
impl TypePath for Vec4
impl TypePath for ViewVisibility
impl TypePath for Virtual
impl TypePath for Window
impl TypePath for WindowMoved
impl TypePath for WindowResizeConstraints
impl TypePath for Xyza
impl TypePath for CameraMainTextureUsages
impl TypePath for CameraRenderGraph
impl TypePath for Exposure
impl TypePath for ManualTextureViewHandle
impl TypePath for MipBias
impl TypePath for SubCameraView
impl TypePath for TemporalJitter
impl TypePath for Viewport
impl TypePath for GlobalsUniform
impl TypePath for ReadbackComplete
impl TypePath for MeshMorphWeights
impl TypePath for SkinnedMesh
impl TypePath for SkinnedMeshInverseBindposes
impl TypePath for Aabb
impl TypePath for CascadesFrusta
impl TypePath for CubemapFrusta
impl TypePath for Frustum
impl TypePath for ShaderStorageBuffer
impl TypePath for SyncToRenderWorld
impl TypePath for TemporaryRenderEntity
impl TypePath for ColorGrading
impl TypePath for ColorGradingGlobal
impl TypePath for ColorGradingSection
impl TypePath for NoFrustumCulling
impl TypePath for RenderLayers
impl TypePath for RenderVisibleEntities
impl TypePath for VisibilityRange
impl TypePath for VisibleEntities
impl TypePath for Screenshot
impl TypePath for ScreenshotCaptured
impl TypePath for Stopwatch
impl TypePath for Duration
impl TypePath for FixedState
impl TypePath for Instant
impl TypePath for NoOpHash
impl TypePath for CursorOptions
impl TypePath for EnabledButtons
impl TypePath for InternalWindowState
impl TypePath for Monitor
impl TypePath for NormalizedWindowRef
impl TypePath for PrimaryMonitor
impl TypePath for PrimaryWindow
impl TypePath for RequestRedraw
impl TypePath for VideoMode
impl TypePath for WindowBackendScaleFactorChanged
impl TypePath for WindowCloseRequested
impl TypePath for WindowClosed
impl TypePath for WindowClosing
impl TypePath for WindowCreated
impl TypePath for WindowDestroyed
impl TypePath for WindowFocused
impl TypePath for WindowOccluded
impl TypePath for WindowResized
impl TypePath for WindowResolution
impl TypePath for WindowScaleFactorChanged
impl TypePath for WindowThemeChanged
impl TypePath for WakeUp
impl TypePath for DynamicArray
impl TypePath for DynamicEnum
impl TypePath for DynamicList
impl TypePath for DynamicMap
impl TypePath for DynamicSet
impl TypePath for DynamicStruct
impl TypePath for DynamicTuple
impl TypePath for DynamicTupleStruct
impl TypePath for dyn PartialReflect
impl TypePath for dyn Reflect
impl<'a> TypePath for AssetPath<'a>
impl<A> TypePath for AssetEvent<A>
impl<A> TypePath for AssetId<A>
impl<A> TypePath for Handle<A>
impl<B, E> TypePath for ExtendedMaterial<B, E>where
B: Material + TypePath,
E: MaterialExtension + TypePath,
ExtendedMaterial<B, E>: Any + Send + Sync,
impl<E> TypePath for EventId<E>
impl<E> TypePath for Events<E>
impl<E> TypePath for Pointer<E>
impl<K, V, S> TypePath for bevy::utils::hashbrown::HashMap<K, V, S>
impl<M> TypePath for MeshMaterial3d<M>
impl<P> TypePath for LinearSpline<P>
impl<P> TypePath for CubicBSpline<P>
impl<P> TypePath for CubicBezier<P>
impl<P> TypePath for CubicCardinalSpline<P>
impl<P> TypePath for CubicCurve<P>
impl<P> TypePath for CubicHermite<P>
impl<P> TypePath for CubicNurbs<P>
impl<P> TypePath for CubicSegment<P>
impl<P> TypePath for RationalCurve<P>
impl<P> TypePath for RationalSegment<P>
impl<S, T, C, D> TypePath for ZipCurve<S, T, C, D>
impl<S, T, C, F> TypePath for MapCurve<S, T, C, F>
bevy_reflect
only.Note: This is not a fully stable implementation of TypePath
due to usage of type_name
for function members.
impl<T> TypePath for InterpolationDatum<T>
impl<T> TypePath for ColorCurve<T>
impl<T> TypePath for ChunkedUnevenCore<T>
impl<T> TypePath for EvenCore<T>
impl<T> TypePath for UnevenCore<T>
impl<T> TypePath for Axis<T>
impl<T> TypePath for ButtonInput<T>
impl<T> TypePath for ConstantCurve<T>
impl<T> TypePath for EasingCurve<T>
impl<T> TypePath for SampleAutoCurve<T>
impl<T> TypePath for Time<T>
impl<T> TypePath for UnevenSampleAutoCurve<T>
impl<T, C> TypePath for ForeverCurve<T, C>
impl<T, C> TypePath for GraphCurve<T, C>
impl<T, C> TypePath for LinearReparamCurve<T, C>
impl<T, C> TypePath for PingPongCurve<T, C>
impl<T, C> TypePath for RepeatCurve<T, C>
impl<T, C> TypePath for ReverseCurve<T, C>
impl<T, C, D> TypePath for ChainCurve<T, C, D>
impl<T, C, D> TypePath for ContinuationCurve<T, C, D>
impl<T, C, D> TypePath for CurveReparamCurve<T, C, D>
impl<T, C, F> TypePath for ReparamCurve<T, C, F>
bevy_reflect
only.Note: This is not a fully stable implementation of TypePath
due to usage of type_name
for function members.
impl<T, F> TypePath for FunctionCurve<T, F>where
T: TypePath,
F: 'static,
bevy_reflect
only.Note: This is not a fully stable implementation of TypePath
due to usage of type_name
for function members.
impl<T, I> TypePath for SampleCurve<T, I>where
T: TypePath,
I: 'static,
bevy_reflect
only.Note: This is not a fully stable implementation of TypePath
due to usage of type_name
for function members.
impl<T, I> TypePath for UnevenSampleCurve<T, I>where
T: TypePath,
I: 'static,
bevy_reflect
only.Note: This is not a fully stable implementation of TypePath
due to usage of type_name
for function members.