State

Struct State 

Source
pub struct State<S>(/* private fields */)
where
    S: States;
Expand description

A finite-state machine whose transitions have associated schedules (OnEnter(state) and OnExit(state)).

The current state value can be accessed through this resource. To change the state, queue a transition in the NextState<S> resource, and it will be applied during the StateTransition schedule - which by default runs after PreUpdate.

You can also manually trigger the StateTransition schedule to apply the changes at an arbitrary time.

The starting state is defined via the Default implementation for S.

use bevy_state::prelude::*;
use bevy_ecs::prelude::*;
use bevy_state_macros::States;

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Default, States)]
enum GameState {
    #[default]
    MainMenu,
    SettingsMenu,
    InGame,
}

fn game_logic(game_state: Res<State<GameState>>) {
    match game_state.get() {
        GameState::InGame => {
            // Run game logic here...
        },
        _ => {},
    }
}

Implementations§

Source§

impl<S> State<S>
where S: States,

Source

pub fn new(state: S) -> State<S>

Creates a new state with a specific value.

To change the state use NextState<S> rather than using this to modify the State<S>.

Source

pub fn get(&self) -> &S

Get the current state.

Examples found in repository?
examples/testbed/2d.rs (line 57)
50fn switch_scene(
51    keyboard: Res<ButtonInput<KeyCode>>,
52    scene: Res<State<Scene>>,
53    mut next_scene: ResMut<NextState<Scene>>,
54) {
55    if keyboard.just_pressed(KeyCode::Space) {
56        info!("Switching scene");
57        next_scene.set(scene.get().next());
58    }
59}
More examples
Hide additional examples
examples/testbed/3d.rs (line 68)
61fn switch_scene(
62    keyboard: Res<ButtonInput<KeyCode>>,
63    scene: Res<State<Scene>>,
64    mut next_scene: ResMut<NextState<Scene>>,
65) {
66    if keyboard.just_pressed(KeyCode::Space) {
67        info!("Switching scene");
68        next_scene.set(scene.get().next());
69    }
70}
examples/testbed/ui.rs (line 75)
68fn switch_scene(
69    keyboard: Res<ButtonInput<KeyCode>>,
70    scene: Res<State<Scene>>,
71    mut next_scene: ResMut<NextState<Scene>>,
72) {
73    if keyboard.just_pressed(KeyCode::Space) {
74        info!("Switching scene");
75        next_scene.set(scene.get().next());
76    }
77}
examples/state/sub_states.rs (line 134)
128fn toggle_pause(
129    input: Res<ButtonInput<KeyCode>>,
130    current_state: Res<State<IsPaused>>,
131    mut next_state: ResMut<NextState<IsPaused>>,
132) {
133    if input.just_pressed(KeyCode::Space) {
134        next_state.set(match current_state.get() {
135            IsPaused::Running => IsPaused::Paused,
136            IsPaused::Paused => IsPaused::Running,
137        });
138    }
139}
examples/ecs/state_scoped.rs (line 122)
113fn toggle(
114    time: Res<Time>,
115    mut timer: ResMut<TickTock>,
116    state: Res<State<GameState>>,
117    mut next_state: ResMut<NextState<GameState>>,
118) {
119    if !timer.0.tick(time.delta()).is_finished() {
120        return;
121    }
122    *next_state = match state.get() {
123        GameState::A => NextState::Pending(GameState::B),
124        GameState::B => NextState::Pending(GameState::A),
125    }
126}
examples/math/render_primitives.rs (line 315)
307fn update_active_cameras(
308    state: Res<State<CameraActive>>,
309    camera_2d: Single<(Entity, &mut Camera), With<Camera2d>>,
310    camera_3d: Single<(Entity, &mut Camera), (With<Camera3d>, Without<Camera2d>)>,
311    mut text: Query<&mut UiTargetCamera, With<HeaderNode>>,
312) {
313    let (entity_2d, mut cam_2d) = camera_2d.into_inner();
314    let (entity_3d, mut cam_3d) = camera_3d.into_inner();
315    let is_camera_2d_active = matches!(*state.get(), CameraActive::Dim2);
316
317    cam_2d.is_active = is_camera_2d_active;
318    cam_3d.is_active = !is_camera_2d_active;
319
320    let active_camera = if is_camera_2d_active {
321        entity_2d
322    } else {
323        entity_3d
324    };
325
326    text.iter_mut().for_each(|mut target_camera| {
327        *target_camera = UiTargetCamera(active_camera);
328    });
329}
330
331fn switch_cameras(current: Res<State<CameraActive>>, mut next: ResMut<NextState<CameraActive>>) {
332    let next_state = match current.get() {
333        CameraActive::Dim2 => CameraActive::Dim3,
334        CameraActive::Dim3 => CameraActive::Dim2,
335    };
336    next.set(next_state);
337}
338
339fn setup_text(mut commands: Commands, cameras: Query<(Entity, &Camera)>) {
340    let active_camera = cameras
341        .iter()
342        .find_map(|(entity, camera)| camera.is_active.then_some(entity))
343        .expect("run condition ensures existence");
344    commands.spawn((
345        HeaderNode,
346        Node {
347            justify_self: JustifySelf::Center,
348            top: px(5),
349            ..Default::default()
350        },
351        UiTargetCamera(active_camera),
352        children![(
353            Text::default(),
354            HeaderText,
355            TextLayout::new_with_justify(Justify::Center),
356            children![
357                TextSpan::new("Primitive: "),
358                TextSpan(format!("{text}", text = PrimitiveSelected::default())),
359                TextSpan::new("\n\n"),
360                TextSpan::new(
361                    "Press 'C' to switch between 2D and 3D mode\n\
362                    Press 'Up' or 'Down' to switch to the next/previous primitive",
363                ),
364                TextSpan::new("\n\n"),
365                TextSpan::new("(If nothing is displayed, there's no rendering support yet)",),
366            ]
367        )],
368    ));
369}
370
371fn update_text(
372    primitive_state: Res<State<PrimitiveSelected>>,
373    header: Query<Entity, With<HeaderText>>,
374    mut writer: TextUiWriter,
375) {
376    let new_text = format!("{text}", text = primitive_state.get());
377    header.iter().for_each(|header_text| {
378        if let Some(mut text) = writer.get_text(header_text, 2) {
379            (*text).clone_from(&new_text);
380        };
381    });
382}
383
384fn switch_to_next_primitive(
385    current: Res<State<PrimitiveSelected>>,
386    mut next: ResMut<NextState<PrimitiveSelected>>,
387) {
388    let next_state = current.get().next();
389    next.set(next_state);
390}
391
392fn switch_to_previous_primitive(
393    current: Res<State<PrimitiveSelected>>,
394    mut next: ResMut<NextState<PrimitiveSelected>>,
395) {
396    let next_state = current.get().previous();
397    next.set(next_state);
398}
399
400fn in_mode(active: CameraActive) -> impl Fn(Res<State<CameraActive>>) -> bool {
401    move |state| *state.get() == active
402}
403
404fn draw_gizmos_2d(mut gizmos: Gizmos, state: Res<State<PrimitiveSelected>>, time: Res<Time>) {
405    const POSITION: Vec2 = Vec2::new(-LEFT_RIGHT_OFFSET_2D, 0.0);
406    let angle = time.elapsed_secs();
407    let isometry = Isometry2d::new(POSITION, Rot2::radians(angle));
408    let color = Color::WHITE;
409
410    #[expect(
411        clippy::match_same_arms,
412        reason = "Certain primitives don't have any 2D rendering support yet."
413    )]
414    match state.get() {
415        PrimitiveSelected::RectangleAndCuboid => {
416            gizmos.primitive_2d(&RECTANGLE, isometry, color);
417        }
418        PrimitiveSelected::CircleAndSphere => {
419            gizmos.primitive_2d(&CIRCLE, isometry, color);
420        }
421        PrimitiveSelected::Ellipse => drop(gizmos.primitive_2d(&ELLIPSE, isometry, color)),
422        PrimitiveSelected::Triangle => gizmos.primitive_2d(&TRIANGLE_2D, isometry, color),
423        PrimitiveSelected::Plane => gizmos.primitive_2d(&PLANE_2D, isometry, color),
424        PrimitiveSelected::Line => drop(gizmos.primitive_2d(&LINE2D, isometry, color)),
425        PrimitiveSelected::Segment => {
426            drop(gizmos.primitive_2d(&SEGMENT_2D, isometry, color));
427        }
428        PrimitiveSelected::Polyline => gizmos.primitive_2d(
429            &Polyline2d {
430                vertices: vec![
431                    Vec2::new(-BIG_2D, -SMALL_2D),
432                    Vec2::new(-SMALL_2D, SMALL_2D),
433                    Vec2::new(SMALL_2D, -SMALL_2D),
434                    Vec2::new(BIG_2D, SMALL_2D),
435                ],
436            },
437            isometry,
438            color,
439        ),
440        PrimitiveSelected::Polygon => gizmos.primitive_2d(
441            &Polygon {
442                vertices: vec![
443                    Vec2::new(-BIG_2D, -SMALL_2D),
444                    Vec2::new(BIG_2D, -SMALL_2D),
445                    Vec2::new(BIG_2D, SMALL_2D),
446                    Vec2::new(0.0, 0.0),
447                    Vec2::new(-BIG_2D, SMALL_2D),
448                ],
449            },
450            isometry,
451            color,
452        ),
453        PrimitiveSelected::RegularPolygon => {
454            gizmos.primitive_2d(&REGULAR_POLYGON, isometry, color);
455        }
456        PrimitiveSelected::Capsule => gizmos.primitive_2d(&CAPSULE_2D, isometry, color),
457        PrimitiveSelected::Cylinder => {}
458        PrimitiveSelected::Cone => {}
459        PrimitiveSelected::ConicalFrustum => {}
460        PrimitiveSelected::Torus => drop(gizmos.primitive_2d(&ANNULUS, isometry, color)),
461        PrimitiveSelected::Tetrahedron => {}
462        PrimitiveSelected::Arc => gizmos.primitive_2d(&ARC, isometry, color),
463        PrimitiveSelected::CircularSector => {
464            gizmos.primitive_2d(&CIRCULAR_SECTOR, isometry, color);
465        }
466        PrimitiveSelected::CircularSegment => {
467            gizmos.primitive_2d(&CIRCULAR_SEGMENT, isometry, color);
468        }
469    }
470}
471
472/// Marker for primitive meshes to record in which state they should be visible in
473#[derive(Debug, Clone, Component, Default, Reflect)]
474pub struct PrimitiveData {
475    camera_mode: CameraActive,
476    primitive_state: PrimitiveSelected,
477}
478
479/// Marker for meshes of 2D primitives
480#[derive(Debug, Clone, Component, Default)]
481pub struct MeshDim2;
482
483/// Marker for meshes of 3D primitives
484#[derive(Debug, Clone, Component, Default)]
485pub struct MeshDim3;
486
487fn spawn_primitive_2d(
488    mut commands: Commands,
489    mut materials: ResMut<Assets<ColorMaterial>>,
490    mut meshes: ResMut<Assets<Mesh>>,
491) {
492    const POSITION: Vec3 = Vec3::new(LEFT_RIGHT_OFFSET_2D, 0.0, 0.0);
493    let material: Handle<ColorMaterial> = materials.add(Color::WHITE);
494    let camera_mode = CameraActive::Dim2;
495    [
496        Some(RECTANGLE.mesh().build()),
497        Some(CIRCLE.mesh().build()),
498        Some(ELLIPSE.mesh().build()),
499        Some(TRIANGLE_2D.mesh().build()),
500        None, // plane
501        None, // line
502        None, // segment
503        None, // polyline
504        None, // polygon
505        Some(REGULAR_POLYGON.mesh().build()),
506        Some(CAPSULE_2D.mesh().build()),
507        None, // cylinder
508        None, // cone
509        None, // conical frustum
510        Some(ANNULUS.mesh().build()),
511        None, // tetrahedron
512    ]
513    .into_iter()
514    .zip(PrimitiveSelected::ALL)
515    .for_each(|(maybe_mesh, state)| {
516        if let Some(mesh) = maybe_mesh {
517            commands.spawn((
518                MeshDim2,
519                PrimitiveData {
520                    camera_mode,
521                    primitive_state: state,
522                },
523                Mesh2d(meshes.add(mesh)),
524                MeshMaterial2d(material.clone()),
525                Transform::from_translation(POSITION),
526            ));
527        }
528    });
529}
530
531fn spawn_primitive_3d(
532    mut commands: Commands,
533    mut materials: ResMut<Assets<StandardMaterial>>,
534    mut meshes: ResMut<Assets<Mesh>>,
535) {
536    const POSITION: Vec3 = Vec3::new(-LEFT_RIGHT_OFFSET_3D, 0.0, 0.0);
537    let material: Handle<StandardMaterial> = materials.add(Color::WHITE);
538    let camera_mode = CameraActive::Dim3;
539    [
540        Some(CUBOID.mesh().build()),
541        Some(SPHERE.mesh().build()),
542        None, // ellipse
543        Some(TRIANGLE_3D.mesh().build()),
544        Some(PLANE_3D.mesh().build()),
545        None, // line
546        None, // segment
547        None, // polyline
548        None, // polygon
549        None, // regular polygon
550        Some(CAPSULE_3D.mesh().build()),
551        Some(CYLINDER.mesh().build()),
552        None, // cone
553        None, // conical frustum
554        Some(TORUS.mesh().build()),
555        Some(TETRAHEDRON.mesh().build()),
556    ]
557    .into_iter()
558    .zip(PrimitiveSelected::ALL)
559    .for_each(|(maybe_mesh, state)| {
560        if let Some(mesh) = maybe_mesh {
561            commands.spawn((
562                MeshDim3,
563                PrimitiveData {
564                    camera_mode,
565                    primitive_state: state,
566                },
567                Mesh3d(meshes.add(mesh)),
568                MeshMaterial3d(material.clone()),
569                Transform::from_translation(POSITION),
570            ));
571        }
572    });
573}
574
575fn update_primitive_meshes(
576    camera_state: Res<State<CameraActive>>,
577    primitive_state: Res<State<PrimitiveSelected>>,
578    mut primitives: Query<(&mut Visibility, &PrimitiveData)>,
579) {
580    primitives.iter_mut().for_each(|(mut vis, primitive)| {
581        let visible = primitive.camera_mode == *camera_state.get()
582            && primitive.primitive_state == *primitive_state.get();
583        *vis = if visible {
584            Visibility::Inherited
585        } else {
586            Visibility::Hidden
587        };
588    });
589}
590
591fn rotate_primitive_2d_meshes(
592    mut primitives_2d: Query<
593        (&mut Transform, &ViewVisibility),
594        (With<PrimitiveData>, With<MeshDim2>),
595    >,
596    time: Res<Time>,
597) {
598    let rotation_2d = Quat::from_mat3(&Mat3::from_angle(time.elapsed_secs()));
599    primitives_2d
600        .iter_mut()
601        .filter(|(_, vis)| vis.get())
602        .for_each(|(mut transform, _)| {
603            transform.rotation = rotation_2d;
604        });
605}
606
607fn rotate_primitive_3d_meshes(
608    mut primitives_3d: Query<
609        (&mut Transform, &ViewVisibility),
610        (With<PrimitiveData>, With<MeshDim3>),
611    >,
612    time: Res<Time>,
613) {
614    let rotation_3d = Quat::from_rotation_arc(
615        Vec3::Z,
616        Vec3::new(
617            ops::sin(time.elapsed_secs()),
618            ops::cos(time.elapsed_secs()),
619            ops::sin(time.elapsed_secs()) * 0.5,
620        )
621        .try_normalize()
622        .unwrap_or(Vec3::Z),
623    );
624    primitives_3d
625        .iter_mut()
626        .filter(|(_, vis)| vis.get())
627        .for_each(|(mut transform, _)| {
628            transform.rotation = rotation_3d;
629        });
630}
631
632fn draw_gizmos_3d(mut gizmos: Gizmos, state: Res<State<PrimitiveSelected>>, time: Res<Time>) {
633    const POSITION: Vec3 = Vec3::new(LEFT_RIGHT_OFFSET_3D, 0.0, 0.0);
634    let rotation = Quat::from_rotation_arc(
635        Vec3::Z,
636        Vec3::new(
637            ops::sin(time.elapsed_secs()),
638            ops::cos(time.elapsed_secs()),
639            ops::sin(time.elapsed_secs()) * 0.5,
640        )
641        .try_normalize()
642        .unwrap_or(Vec3::Z),
643    );
644    let isometry = Isometry3d::new(POSITION, rotation);
645    let color = Color::WHITE;
646    let resolution = 10;
647
648    #[expect(
649        clippy::match_same_arms,
650        reason = "Certain primitives don't have any 3D rendering support yet."
651    )]
652    match state.get() {
653        PrimitiveSelected::RectangleAndCuboid => {
654            gizmos.primitive_3d(&CUBOID, isometry, color);
655        }
656        PrimitiveSelected::CircleAndSphere => drop(
657            gizmos
658                .primitive_3d(&SPHERE, isometry, color)
659                .resolution(resolution),
660        ),
661        PrimitiveSelected::Ellipse => {}
662        PrimitiveSelected::Triangle => gizmos.primitive_3d(&TRIANGLE_3D, isometry, color),
663        PrimitiveSelected::Plane => drop(gizmos.primitive_3d(&PLANE_3D, isometry, color)),
664        PrimitiveSelected::Line => gizmos.primitive_3d(&LINE3D, isometry, color),
665        PrimitiveSelected::Segment => gizmos.primitive_3d(&SEGMENT_3D, isometry, color),
666        PrimitiveSelected::Polyline => gizmos.primitive_3d(
667            &Polyline3d {
668                vertices: vec![
669                    Vec3::new(-BIG_3D, -SMALL_3D, -SMALL_3D),
670                    Vec3::new(SMALL_3D, SMALL_3D, 0.0),
671                    Vec3::new(-SMALL_3D, -SMALL_3D, 0.0),
672                    Vec3::new(BIG_3D, SMALL_3D, SMALL_3D),
673                ],
674            },
675            isometry,
676            color,
677        ),
678        PrimitiveSelected::Polygon => {}
679        PrimitiveSelected::RegularPolygon => {}
680        PrimitiveSelected::Capsule => drop(
681            gizmos
682                .primitive_3d(&CAPSULE_3D, isometry, color)
683                .resolution(resolution),
684        ),
685        PrimitiveSelected::Cylinder => drop(
686            gizmos
687                .primitive_3d(&CYLINDER, isometry, color)
688                .resolution(resolution),
689        ),
690        PrimitiveSelected::Cone => drop(
691            gizmos
692                .primitive_3d(&CONE, isometry, color)
693                .resolution(resolution),
694        ),
695        PrimitiveSelected::ConicalFrustum => {
696            gizmos.primitive_3d(&CONICAL_FRUSTUM, isometry, color);
697        }
698
699        PrimitiveSelected::Torus => drop(
700            gizmos
701                .primitive_3d(&TORUS, isometry, color)
702                .minor_resolution(resolution)
703                .major_resolution(resolution),
704        ),
705        PrimitiveSelected::Tetrahedron => {
706            gizmos.primitive_3d(&TETRAHEDRON, isometry, color);
707        }
708
709        PrimitiveSelected::Arc => {}
710        PrimitiveSelected::CircularSector => {}
711        PrimitiveSelected::CircularSegment => {}
712    }
713}

Trait Implementations§

Source§

impl<S> Debug for State<S>
where S: Debug + States,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S> Deref for State<S>
where S: States,

Source§

type Target = S

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<State<S> as Deref>::Target

Dereferences the value.
Source§

impl<S> FromArg for State<S>
where S: States + TypePath + FromReflect + MaybeTyped + RegisterForReflection, State<S>: Any + Send + Sync,

Source§

type This<'from_arg> = State<S>

The type to convert into. Read more
Source§

fn from_arg(arg: Arg<'_>) -> Result<<State<S> as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl<S> FromReflect for State<S>
where S: States + TypePath + FromReflect + MaybeTyped + RegisterForReflection, State<S>: Any + Send + Sync,

Source§

fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<State<S>>

Constructs a concrete instance of Self from a reflected value.
Source§

fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>

Attempts to downcast the given value to Self using, constructing the value using from_reflect if that fails. Read more
Source§

impl<S> FromWorld for State<S>
where S: States + FromWorld,

Source§

fn from_world(world: &mut World) -> State<S>

Creates Self using data from the given World.
Source§

impl<S> GetOwnership for State<S>
where S: States + TypePath + FromReflect + MaybeTyped + RegisterForReflection, State<S>: Any + Send + Sync,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl<S> GetTypeRegistration for State<S>
where S: States + TypePath + FromReflect + MaybeTyped + RegisterForReflection, State<S>: Any + Send + Sync,

Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl<S> IntoReturn for State<S>
where S: States + TypePath + FromReflect + MaybeTyped + RegisterForReflection, State<S>: Any + Send + Sync,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where State<S>: 'into_return,

Converts Self into a Return value.
Source§

impl<S> PartialEq<S> for State<S>
where S: States,

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

impl<S> PartialReflect for State<S>
where S: States + TypePath + FromReflect + MaybeTyped + RegisterForReflection, State<S>: Any + Send + Sync,

Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<State<S>>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_into_reflect( self: Box<State<S>>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>

Attempts to cast this type to a boxed, fully-reflected value.
Source§

fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>

Attempts to cast this type to a fully-reflected value.
Source§

fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>

Attempts to cast this type to a mutable, fully-reflected value.
Source§

fn into_partial_reflect(self: Box<State<S>>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)

Casts this type to a reflected value. Read more
Source§

fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)

Casts this type to a mutable, reflected value. Read more
Source§

fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

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

Debug formatter for the value. Read more
Source§

fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>

Attempts to clone Self using reflection. Read more
Source§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
Source§

fn to_dynamic(&self) -> Box<dyn PartialReflect>

Converts this reflected value into its dynamic representation based on its kind. Read more
Source§

fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
where T: 'static, Self: Sized + TypePath,

For a type implementing PartialReflect, combines reflect_clone and take in a useful fashion, automatically constructing an appropriate ReflectCloneError if the downcast fails. Read more
Source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
Source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl<S> Reflect for State<S>
where S: States + TypePath + FromReflect + MaybeTyped + RegisterForReflection, State<S>: Any + Send + Sync,

Source§

fn into_any(self: Box<State<S>>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>. Read more
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the value as a &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<State<S>>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

fn as_reflect(&self) -> &(dyn Reflect + 'static)

Casts this type to a fully-reflected value.
Source§

fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl<S> TupleStruct for State<S>
where S: States + TypePath + FromReflect + MaybeTyped + RegisterForReflection, State<S>: Any + Send + Sync,

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

impl<S> TypePath for State<S>
where S: States + TypePath, State<S>: Any + Send + Sync,

Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
Source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl<S> Typed for State<S>
where S: States + TypePath + FromReflect + MaybeTyped + RegisterForReflection, State<S>: Any + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.
Source§

impl<S> Resource for State<S>
where S: States, State<S>: Send + Sync + 'static,

Auto Trait Implementations§

§

impl<S> Freeze for State<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for State<S>
where S: RefUnwindSafe,

§

impl<S> Send for State<S>

§

impl<S> Sync for State<S>

§

impl<S> Unpin for State<S>
where S: Unpin,

§

impl<S> UnwindSafe for State<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T, C, D> Curve<T> for D
where C: Curve<T> + ?Sized, D: Deref<Target = C>,

Source§

fn domain(&self) -> Interval

The interval over which this curve is parametrized. Read more
Source§

fn sample_unchecked(&self, t: f32) -> T

Sample a point on this curve at the parameter value t, extracting the associated value. This is the unchecked version of sampling, which should only be used if the sample time t is already known to lie within the curve’s domain. Read more
Source§

fn sample(&self, t: f32) -> Option<T>

Sample a point on this curve at the parameter value t, returning None if the point is outside of the curve’s domain.
Source§

fn sample_clamped(&self, t: f32) -> T

Sample a point on this curve at the parameter value t, clamping t to lie inside the domain of the curve.
Source§

impl<C, T> CurveExt<T> for C
where C: Curve<T>,

Source§

fn sample_iter( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = Option<T>>

Sample a collection of n >= 0 points on this curve at the parameter values t_n, returning None if the point is outside of the curve’s domain. Read more
Source§

fn sample_iter_unchecked( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>

Sample a collection of n >= 0 points on this curve at the parameter values t_n, extracting the associated values. This is the unchecked version of sampling, which should only be used if the sample times t_n are already known to lie within the curve’s domain. Read more
Source§

fn sample_iter_clamped( &self, iter: impl IntoIterator<Item = f32>, ) -> impl Iterator<Item = T>

Sample a collection of n >= 0 points on this curve at the parameter values t_n, clamping t_n to lie inside the domain of the curve. Read more
Source§

fn map<S, F>(self, f: F) -> MapCurve<T, S, Self, F>
where F: Fn(T) -> S,

Create a new curve by mapping the values of this curve via a function f; i.e., if the sample at time t for this curve is x, the value at time t on the new curve will be f(x).
Source§

fn reparametrize<F>(self, domain: Interval, f: F) -> ReparamCurve<T, Self, F>
where F: Fn(f32) -> f32,

Create a new Curve whose parameter space is related to the parameter space of this curve by f. For each time t, the sample from the new curve at time t is the sample from this curve at time f(t). The given domain will be the domain of the new curve. The function f is expected to take domain into self.domain(). Read more
Source§

fn reparametrize_linear( self, domain: Interval, ) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>

Linearly reparametrize this Curve, producing a new curve whose domain is the given domain instead of the current one. This operation is only valid for curves with bounded domains. Read more
Source§

fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>
where C: Curve<f32>,

Reparametrize this Curve by sampling from another curve. Read more
Source§

fn graph(self) -> GraphCurve<T, Self>

Create a new Curve which is the graph of this one; that is, its output echoes the sample time as part of a tuple. Read more
Source§

fn zip<S, C>( self, other: C, ) -> Result<ZipCurve<T, S, Self, C>, InvalidIntervalError>
where C: Curve<S>,

Create a new Curve by zipping this curve together with another. Read more
Source§

fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>
where C: Curve<T>,

Create a new Curve by composing this curve end-to-start with another, producing another curve with outputs of the same type. The domain of the other curve is translated so that its start coincides with where this curve ends. Read more
Source§

fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>

Create a new Curve inverting this curve on the x-axis, producing another curve with outputs of the same type, effectively playing backwards starting at self.domain().end() and transitioning over to self.domain().start(). The domain of the new curve is still the same. Read more
Source§

fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>

Create a new Curve repeating this curve N times, producing another curve with outputs of the same type. The domain of the new curve will be bigger by a factor of n + 1. Read more
Source§

fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>

Create a new Curve repeating this curve forever, producing another curve with outputs of the same type. The domain of the new curve will be unbounded. Read more
Source§

fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>

Create a new Curve chaining the original curve with its inverse, producing another curve with outputs of the same type. The domain of the new curve will be twice as long. The transition point is guaranteed to not make any jumps. Read more
Source§

fn chain_continue<C>( self, other: C, ) -> Result<ContinuationCurve<T, Self, C>, ChainError>
where T: VectorSpace, C: Curve<T>,

Create a new Curve by composing this curve end-to-start with another, producing another curve with outputs of the same type. The domain of the other curve is translated so that its start coincides with where this curve ends. Read more
Source§

fn samples( &self, samples: usize, ) -> Result<impl Iterator<Item = T>, ResamplingError>

Extract an iterator over evenly-spaced samples from this curve. Read more
Source§

fn by_ref(&self) -> &Self

Borrow this curve rather than taking ownership of it. This is essentially an alias for a prefix &; the point is that intermediate operations can be performed while retaining access to the original curve. Read more
Source§

fn flip<U, V>(self) -> impl Curve<(V, U)>
where Self: CurveExt<(U, V)>,

Flip this curve so that its tuple output is arranged the other way.
Source§

impl<C, T> CurveResampleExt<T> for C
where C: Curve<T> + ?Sized,

Source§

fn resample<I>( &self, segments: usize, interpolation: I, ) -> Result<SampleCurve<T, I>, ResamplingError>
where I: Fn(&T, &T, f32) -> T,

Resample this Curve to produce a new one that is defined by interpolation over equally spaced sample values, using the provided interpolation to interpolate between adjacent samples. The curve is interpolated on segments segments between samples. For example, if segments is 1, only the start and end points of the curve are used as samples; if segments is 2, a sample at the midpoint is taken as well, and so on. Read more
Source§

fn resample_auto( &self, segments: usize, ) -> Result<SampleAutoCurve<T>, ResamplingError>

Resample this Curve to produce a new one that is defined by interpolation over equally spaced sample values, using automatic interpolation to interpolate between adjacent samples. The curve is interpolated on segments segments between samples. For example, if segments is 1, only the start and end points of the curve are used as samples; if segments is 2, a sample at the midpoint is taken as well, and so on. Read more
Source§

fn resample_uneven<I>( &self, sample_times: impl IntoIterator<Item = f32>, interpolation: I, ) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
where I: Fn(&T, &T, f32) -> T,

Resample this Curve to produce a new one that is defined by interpolation over samples taken at a given set of times. The given interpolation is used to interpolate adjacent samples, and the sample_times are expected to contain at least two valid times within the curve’s domain interval. Read more
Source§

fn resample_uneven_auto( &self, sample_times: impl IntoIterator<Item = f32>, ) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>

Resample this Curve to produce a new one that is defined by automatic interpolation over samples taken at the given set of times. The given sample_times are expected to contain at least two valid times within the curve’s domain interval. Read more
Source§

impl<T, C> CurveWithDerivative<T> for C
where T: HasTangent, C: SampleDerivative<T>,

Source§

fn with_derivative(self) -> SampleDerivativeWrapper<C>

This curve, but with its first derivative included in sampling. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynamicTypePath for T
where T: TypePath,

Source§

impl<T> DynamicTyped for T
where T: Typed,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> GetPath for T
where T: Reflect + ?Sized,

Source§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
Source§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
Source§

fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
Source§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
Source§

impl<S> GetTupleStructField for S
where S: 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.
Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

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 T
where 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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, C, D> SampleDerivative<T> for D
where T: HasTangent, C: SampleDerivative<T> + ?Sized, D: Deref<Target = C>,

Source§

fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative<T>

Sample this curve at the parameter value t, extracting the associated value in addition to its derivative. This is the unchecked version of sampling, which should only be used if the sample time t is already known to lie within the curve’s domain. Read more
Source§

fn sample_with_derivative(&self, t: f32) -> Option<WithDerivative<T>>

Sample this curve’s value and derivative at the parameter value t, returning None if the point is outside of the curve’s domain.
Source§

fn sample_with_derivative_clamped(&self, t: f32) -> WithDerivative<T>

Sample this curve’s value and derivative at the parameter value t, clamping t to lie inside the domain of the curve.
Source§

impl<T> Source for T
where T: Deref, <T as Deref>::Target: Source,

Source§

type Slice<'a> = <<T as Deref>::Target as Source>::Slice<'a> where T: 'a

A type this Source can be sliced into.
Source§

fn len(&self) -> usize

Length of the source
Source§

fn read<'a, Chunk>(&'a self, offset: usize) -> Option<Chunk>
where Chunk: Chunk<'a>,

Read a chunk of bytes into an array. Returns None when reading out of bounds would occur. Read more
Source§

unsafe fn read_byte_unchecked(&self, offset: usize) -> u8

Read a byte without doing bounds checks. Read more
Source§

fn slice(&self, range: Range<usize>) -> Option<<T as Source>::Slice<'_>>

Get a slice of the source at given range. This is analogous to slice::get(range). Read more
Source§

unsafe fn slice_unchecked( &self, range: Range<usize>, ) -> <T as Source>::Slice<'_>

Get a slice of the source at given range. This is analogous to slice::get_unchecked(range). Read more
Source§

fn is_boundary(&self, index: usize) -> bool

Check if index is valid for this Source, that is: Read more
Source§

fn find_boundary(&self, index: usize) -> usize

For &str sources attempts to find the closest char boundary at which source can be sliced, starting from index. Read more
Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> Reflectable for T

Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,