Trait IndexEnum

Source
pub trait IndexEnum: EngineEnum {
    const ENUMERATOR_COUNT: usize;

    // Provided method
    fn to_index(self) -> usize { ... }
}
Expand description

Trait for enums that can be used as indices in arrays.

The conditions for a Godot enum to be “index-like” are:

  • Contains an enumerator ending in _MAX, which has the highest ordinal (denotes the size).
  • All other enumerators are consecutive integers inside 0..max (no negative ordinals, no gaps).

Duplicates are explicitly allowed, to allow for renamings/deprecations. The order in which Godot exposes the enumerators in the JSON is irrelevant.

Required Associated Constants§

Source

const ENUMERATOR_COUNT: usize

Number of distinct enumerators in the enum.

All enumerators are guaranteed to be in the range 0..ENUMERATOR_COUNT, so you can use them as indices in an array of size ENUMERATOR_COUNT.

Keep in mind that two enumerators with the same ordinal are only counted once.

Provided Methods§

Source

fn to_index(self) -> usize

Converts the enumerator to usize, which can be used as an array index.

Note that two enumerators may have the same index, if they have the same ordinal.

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.

Implementors§

Source§

impl IndexEnum for VariantOperator

Source§

impl IndexEnum for VariantType

Source§

impl IndexEnum for ClipChildrenMode

Source§

impl IndexEnum for TextureFilter

Source§

impl IndexEnum for TextureRepeat

Source§

impl IndexEnum for DockSlot

Source§

impl IndexEnum for MouseMode

Source§

impl IndexEnum for godot_core::classes::mesh::ArrayCustomFormat

Source§

impl IndexEnum for godot_core::classes::mesh::ArrayType

Source§

impl IndexEnum for godot_core::classes::rendering_server::ArrayCustomFormat

Source§

impl IndexEnum for godot_core::classes::rendering_server::ArrayType

Source§

impl IndexEnum for CanvasItemTextureFilter

Source§

impl IndexEnum for CanvasItemTextureRepeat

Source§

impl IndexEnum for CanvasLightShadowFilter

Source§

impl IndexEnum for DecalTexture

Source§

impl IndexEnum for EnvironmentBg

Source§

impl IndexEnum for EnvironmentSdfgiFramesToConverge

Source§

impl IndexEnum for EnvironmentSdfgiFramesToUpdateLight

Source§

impl IndexEnum for EnvironmentSdfgiRayCount

Source§

impl IndexEnum for FogVolumeShape

Source§

impl IndexEnum for GlobalShaderParameterType

Source§

impl IndexEnum for InstanceFlags

Source§

impl IndexEnum for LightParam

Source§

impl IndexEnum for ParticlesCollisionHeightfieldResolution

Source§

impl IndexEnum for PipelineSource

Source§

impl IndexEnum for PrimitiveType

Source§

impl IndexEnum for ShaderMode

Source§

impl IndexEnum for ShadowQuality

Source§

impl IndexEnum for ViewportAnisotropicFiltering

Source§

impl IndexEnum for ViewportEnvironmentMode

Source§

impl IndexEnum for ViewportMsaa

Source§

impl IndexEnum for ViewportRenderInfo

Source§

impl IndexEnum for ViewportRenderInfoType

Source§

impl IndexEnum for ViewportScaling3DMode

Source§

impl IndexEnum for ViewportScreenSpaceAa

Source§

impl IndexEnum for ViewportSdfOversize

Source§

impl IndexEnum for ViewportSdfScale

Source§

impl IndexEnum for ViewportVrsMode

Source§

impl IndexEnum for ViewportVrsUpdateMode

Source§

impl IndexEnum for CodeCompletionKind

Source§

impl IndexEnum for LookupResultType

Source§

impl IndexEnum for AnisotropicFiltering

Source§

impl IndexEnum for DefaultCanvasItemTextureFilter

Source§

impl IndexEnum for DefaultCanvasItemTextureRepeat

Source§

impl IndexEnum for Msaa

Source§

impl IndexEnum for PositionalShadowAtlasQuadrantSubdiv

Source§

impl IndexEnum for RenderInfo

Source§

impl IndexEnum for RenderInfoType

Source§

impl IndexEnum for Scaling3DMode

Source§

impl IndexEnum for ScreenSpaceAa

Source§

impl IndexEnum for SdfOversize

Source§

impl IndexEnum for SdfScale

Source§

impl IndexEnum for VrsMode

Source§

impl IndexEnum for VrsUpdateMode

Source§

impl IndexEnum for Flags

Source§

impl IndexEnum for LayoutDirection