Enum NextState

Source
pub enum NextState<S>{
    Unchanged,
    Pending(S),
}
Expand description

The next state of State<S>.

This can be fetched as a resource and used to queue state transitions. To queue a transition, call NextState::set or mutate the value to NextState::Pending directly.

Note that these transitions can be overridden by other systems: only the actual value of this resource during the StateTransition schedule matters.

use bevy_state::prelude::*;
use bevy_ecs::prelude::*;

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

fn start_game(mut next_game_state: ResMut<NextState<GameState>>) {
    next_game_state.set(GameState::InGame);
}

Variants§

§

Unchanged

No state transition is pending

§

Pending(S)

There is a pending transition for state S

Implementations§

Source§

impl<S> NextState<S>

Source

pub fn set(&mut self, state: S)

Tentatively set a pending state transition to Some(state).

Examples found in repository?
examples/ecs/generic_system.rs (line 79)
74fn transition_to_in_game_system(
75    mut next_state: ResMut<NextState<AppState>>,
76    keyboard_input: Res<ButtonInput<KeyCode>>,
77) {
78    if keyboard_input.pressed(KeyCode::Space) {
79        next_state.set(AppState::InGame);
80    }
81}
More examples
Hide additional examples
examples/games/game_menu.rs (line 105)
99    fn countdown(
100        mut game_state: ResMut<NextState<GameState>>,
101        time: Res<Time>,
102        mut timer: ResMut<SplashTimer>,
103    ) {
104        if timer.tick(time.delta()).finished() {
105            game_state.set(GameState::Menu);
106        }
107    }
108}
109
110mod game {
111    use bevy::{
112        color::palettes::basic::{BLUE, LIME},
113        prelude::*,
114    };
115
116    use super::{despawn_screen, DisplayQuality, GameState, Volume, TEXT_COLOR};
117
118    // This plugin will contain the game. In this case, it's just be a screen that will
119    // display the current settings for 5 seconds before returning to the menu
120    pub fn game_plugin(app: &mut App) {
121        app.add_systems(OnEnter(GameState::Game), game_setup)
122            .add_systems(Update, game.run_if(in_state(GameState::Game)))
123            .add_systems(OnExit(GameState::Game), despawn_screen::<OnGameScreen>);
124    }
125
126    // Tag component used to tag entities added on the game screen
127    #[derive(Component)]
128    struct OnGameScreen;
129
130    #[derive(Resource, Deref, DerefMut)]
131    struct GameTimer(Timer);
132
133    fn game_setup(
134        mut commands: Commands,
135        display_quality: Res<DisplayQuality>,
136        volume: Res<Volume>,
137    ) {
138        commands.spawn((
139            Node {
140                width: Val::Percent(100.0),
141                height: Val::Percent(100.0),
142                // center children
143                align_items: AlignItems::Center,
144                justify_content: JustifyContent::Center,
145                ..default()
146            },
147            OnGameScreen,
148            children![(
149                Node {
150                    // This will display its children in a column, from top to bottom
151                    flex_direction: FlexDirection::Column,
152                    // `align_items` will align children on the cross axis. Here the main axis is
153                    // vertical (column), so the cross axis is horizontal. This will center the
154                    // children
155                    align_items: AlignItems::Center,
156                    ..default()
157                },
158                BackgroundColor(Color::BLACK),
159                children![
160                    (
161                        Text::new("Will be back to the menu shortly..."),
162                        TextFont {
163                            font_size: 67.0,
164                            ..default()
165                        },
166                        TextColor(TEXT_COLOR),
167                        Node {
168                            margin: UiRect::all(Val::Px(50.0)),
169                            ..default()
170                        },
171                    ),
172                    (
173                        Text::default(),
174                        Node {
175                            margin: UiRect::all(Val::Px(50.0)),
176                            ..default()
177                        },
178                        children![
179                            (
180                                TextSpan(format!("quality: {:?}", *display_quality)),
181                                TextFont {
182                                    font_size: 50.0,
183                                    ..default()
184                                },
185                                TextColor(BLUE.into()),
186                            ),
187                            (
188                                TextSpan::new(" - "),
189                                TextFont {
190                                    font_size: 50.0,
191                                    ..default()
192                                },
193                                TextColor(TEXT_COLOR),
194                            ),
195                            (
196                                TextSpan(format!("volume: {:?}", *volume)),
197                                TextFont {
198                                    font_size: 50.0,
199                                    ..default()
200                                },
201                                TextColor(LIME.into()),
202                            ),
203                        ]
204                    ),
205                ]
206            )],
207        ));
208        // Spawn a 5 seconds timer to trigger going back to the menu
209        commands.insert_resource(GameTimer(Timer::from_seconds(5.0, TimerMode::Once)));
210    }
211
212    // Tick the timer, and change state when finished
213    fn game(
214        time: Res<Time>,
215        mut game_state: ResMut<NextState<GameState>>,
216        mut timer: ResMut<GameTimer>,
217    ) {
218        if timer.tick(time.delta()).finished() {
219            game_state.set(GameState::Menu);
220        }
221    }
222}
223
224mod menu {
225    use bevy::{
226        app::AppExit,
227        color::palettes::css::CRIMSON,
228        ecs::spawn::{SpawnIter, SpawnWith},
229        prelude::*,
230    };
231
232    use super::{despawn_screen, DisplayQuality, GameState, Volume, TEXT_COLOR};
233
234    // This plugin manages the menu, with 5 different screens:
235    // - a main menu with "New Game", "Settings", "Quit"
236    // - a settings menu with two submenus and a back button
237    // - two settings screen with a setting that can be set and a back button
238    pub fn menu_plugin(app: &mut App) {
239        app
240            // At start, the menu is not enabled. This will be changed in `menu_setup` when
241            // entering the `GameState::Menu` state.
242            // Current screen in the menu is handled by an independent state from `GameState`
243            .init_state::<MenuState>()
244            .add_systems(OnEnter(GameState::Menu), menu_setup)
245            // Systems to handle the main menu screen
246            .add_systems(OnEnter(MenuState::Main), main_menu_setup)
247            .add_systems(OnExit(MenuState::Main), despawn_screen::<OnMainMenuScreen>)
248            // Systems to handle the settings menu screen
249            .add_systems(OnEnter(MenuState::Settings), settings_menu_setup)
250            .add_systems(
251                OnExit(MenuState::Settings),
252                despawn_screen::<OnSettingsMenuScreen>,
253            )
254            // Systems to handle the display settings screen
255            .add_systems(
256                OnEnter(MenuState::SettingsDisplay),
257                display_settings_menu_setup,
258            )
259            .add_systems(
260                Update,
261                (setting_button::<DisplayQuality>.run_if(in_state(MenuState::SettingsDisplay)),),
262            )
263            .add_systems(
264                OnExit(MenuState::SettingsDisplay),
265                despawn_screen::<OnDisplaySettingsMenuScreen>,
266            )
267            // Systems to handle the sound settings screen
268            .add_systems(OnEnter(MenuState::SettingsSound), sound_settings_menu_setup)
269            .add_systems(
270                Update,
271                setting_button::<Volume>.run_if(in_state(MenuState::SettingsSound)),
272            )
273            .add_systems(
274                OnExit(MenuState::SettingsSound),
275                despawn_screen::<OnSoundSettingsMenuScreen>,
276            )
277            // Common systems to all screens that handles buttons behavior
278            .add_systems(
279                Update,
280                (menu_action, button_system).run_if(in_state(GameState::Menu)),
281            );
282    }
283
284    // State used for the current menu screen
285    #[derive(Clone, Copy, Default, Eq, PartialEq, Debug, Hash, States)]
286    enum MenuState {
287        Main,
288        Settings,
289        SettingsDisplay,
290        SettingsSound,
291        #[default]
292        Disabled,
293    }
294
295    // Tag component used to tag entities added on the main menu screen
296    #[derive(Component)]
297    struct OnMainMenuScreen;
298
299    // Tag component used to tag entities added on the settings menu screen
300    #[derive(Component)]
301    struct OnSettingsMenuScreen;
302
303    // Tag component used to tag entities added on the display settings menu screen
304    #[derive(Component)]
305    struct OnDisplaySettingsMenuScreen;
306
307    // Tag component used to tag entities added on the sound settings menu screen
308    #[derive(Component)]
309    struct OnSoundSettingsMenuScreen;
310
311    const NORMAL_BUTTON: Color = Color::srgb(0.15, 0.15, 0.15);
312    const HOVERED_BUTTON: Color = Color::srgb(0.25, 0.25, 0.25);
313    const HOVERED_PRESSED_BUTTON: Color = Color::srgb(0.25, 0.65, 0.25);
314    const PRESSED_BUTTON: Color = Color::srgb(0.35, 0.75, 0.35);
315
316    // Tag component used to mark which setting is currently selected
317    #[derive(Component)]
318    struct SelectedOption;
319
320    // All actions that can be triggered from a button click
321    #[derive(Component)]
322    enum MenuButtonAction {
323        Play,
324        Settings,
325        SettingsDisplay,
326        SettingsSound,
327        BackToMainMenu,
328        BackToSettings,
329        Quit,
330    }
331
332    // This system handles changing all buttons color based on mouse interaction
333    fn button_system(
334        mut interaction_query: Query<
335            (&Interaction, &mut BackgroundColor, Option<&SelectedOption>),
336            (Changed<Interaction>, With<Button>),
337        >,
338    ) {
339        for (interaction, mut background_color, selected) in &mut interaction_query {
340            *background_color = match (*interaction, selected) {
341                (Interaction::Pressed, _) | (Interaction::None, Some(_)) => PRESSED_BUTTON.into(),
342                (Interaction::Hovered, Some(_)) => HOVERED_PRESSED_BUTTON.into(),
343                (Interaction::Hovered, None) => HOVERED_BUTTON.into(),
344                (Interaction::None, None) => NORMAL_BUTTON.into(),
345            }
346        }
347    }
348
349    // This system updates the settings when a new value for a setting is selected, and marks
350    // the button as the one currently selected
351    fn setting_button<T: Resource + Component + PartialEq + Copy>(
352        interaction_query: Query<(&Interaction, &T, Entity), (Changed<Interaction>, With<Button>)>,
353        selected_query: Single<(Entity, &mut BackgroundColor), With<SelectedOption>>,
354        mut commands: Commands,
355        mut setting: ResMut<T>,
356    ) {
357        let (previous_button, mut previous_button_color) = selected_query.into_inner();
358        for (interaction, button_setting, entity) in &interaction_query {
359            if *interaction == Interaction::Pressed && *setting != *button_setting {
360                *previous_button_color = NORMAL_BUTTON.into();
361                commands.entity(previous_button).remove::<SelectedOption>();
362                commands.entity(entity).insert(SelectedOption);
363                *setting = *button_setting;
364            }
365        }
366    }
367
368    fn menu_setup(mut menu_state: ResMut<NextState<MenuState>>) {
369        menu_state.set(MenuState::Main);
370    }
371
372    fn main_menu_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
373        // Common style for all buttons on the screen
374        let button_node = Node {
375            width: Val::Px(300.0),
376            height: Val::Px(65.0),
377            margin: UiRect::all(Val::Px(20.0)),
378            justify_content: JustifyContent::Center,
379            align_items: AlignItems::Center,
380            ..default()
381        };
382        let button_icon_node = Node {
383            width: Val::Px(30.0),
384            // This takes the icons out of the flexbox flow, to be positioned exactly
385            position_type: PositionType::Absolute,
386            // The icon will be close to the left border of the button
387            left: Val::Px(10.0),
388            ..default()
389        };
390        let button_text_font = TextFont {
391            font_size: 33.0,
392            ..default()
393        };
394
395        let right_icon = asset_server.load("textures/Game Icons/right.png");
396        let wrench_icon = asset_server.load("textures/Game Icons/wrench.png");
397        let exit_icon = asset_server.load("textures/Game Icons/exitRight.png");
398
399        commands.spawn((
400            Node {
401                width: Val::Percent(100.0),
402                height: Val::Percent(100.0),
403                align_items: AlignItems::Center,
404                justify_content: JustifyContent::Center,
405                ..default()
406            },
407            OnMainMenuScreen,
408            children![(
409                Node {
410                    flex_direction: FlexDirection::Column,
411                    align_items: AlignItems::Center,
412                    ..default()
413                },
414                BackgroundColor(CRIMSON.into()),
415                children![
416                    // Display the game name
417                    (
418                        Text::new("Bevy Game Menu UI"),
419                        TextFont {
420                            font_size: 67.0,
421                            ..default()
422                        },
423                        TextColor(TEXT_COLOR),
424                        Node {
425                            margin: UiRect::all(Val::Px(50.0)),
426                            ..default()
427                        },
428                    ),
429                    // Display three buttons for each action available from the main menu:
430                    // - new game
431                    // - settings
432                    // - quit
433                    (
434                        Button,
435                        button_node.clone(),
436                        BackgroundColor(NORMAL_BUTTON),
437                        MenuButtonAction::Play,
438                        children![
439                            (ImageNode::new(right_icon), button_icon_node.clone()),
440                            (
441                                Text::new("New Game"),
442                                button_text_font.clone(),
443                                TextColor(TEXT_COLOR),
444                            ),
445                        ]
446                    ),
447                    (
448                        Button,
449                        button_node.clone(),
450                        BackgroundColor(NORMAL_BUTTON),
451                        MenuButtonAction::Settings,
452                        children![
453                            (ImageNode::new(wrench_icon), button_icon_node.clone()),
454                            (
455                                Text::new("Settings"),
456                                button_text_font.clone(),
457                                TextColor(TEXT_COLOR),
458                            ),
459                        ]
460                    ),
461                    (
462                        Button,
463                        button_node,
464                        BackgroundColor(NORMAL_BUTTON),
465                        MenuButtonAction::Quit,
466                        children![
467                            (ImageNode::new(exit_icon), button_icon_node),
468                            (Text::new("Quit"), button_text_font, TextColor(TEXT_COLOR),),
469                        ]
470                    ),
471                ]
472            )],
473        ));
474    }
475
476    fn settings_menu_setup(mut commands: Commands) {
477        let button_node = Node {
478            width: Val::Px(200.0),
479            height: Val::Px(65.0),
480            margin: UiRect::all(Val::Px(20.0)),
481            justify_content: JustifyContent::Center,
482            align_items: AlignItems::Center,
483            ..default()
484        };
485
486        let button_text_style = (
487            TextFont {
488                font_size: 33.0,
489                ..default()
490            },
491            TextColor(TEXT_COLOR),
492        );
493
494        commands.spawn((
495            Node {
496                width: Val::Percent(100.0),
497                height: Val::Percent(100.0),
498                align_items: AlignItems::Center,
499                justify_content: JustifyContent::Center,
500                ..default()
501            },
502            OnSettingsMenuScreen,
503            children![(
504                Node {
505                    flex_direction: FlexDirection::Column,
506                    align_items: AlignItems::Center,
507                    ..default()
508                },
509                BackgroundColor(CRIMSON.into()),
510                Children::spawn(SpawnIter(
511                    [
512                        (MenuButtonAction::SettingsDisplay, "Display"),
513                        (MenuButtonAction::SettingsSound, "Sound"),
514                        (MenuButtonAction::BackToMainMenu, "Back"),
515                    ]
516                    .into_iter()
517                    .map(move |(action, text)| {
518                        (
519                            Button,
520                            button_node.clone(),
521                            BackgroundColor(NORMAL_BUTTON),
522                            action,
523                            children![(Text::new(text), button_text_style.clone())],
524                        )
525                    })
526                ))
527            )],
528        ));
529    }
530
531    fn display_settings_menu_setup(mut commands: Commands, display_quality: Res<DisplayQuality>) {
532        fn button_node() -> Node {
533            Node {
534                width: Val::Px(200.0),
535                height: Val::Px(65.0),
536                margin: UiRect::all(Val::Px(20.0)),
537                justify_content: JustifyContent::Center,
538                align_items: AlignItems::Center,
539                ..default()
540            }
541        }
542        fn button_text_style() -> impl Bundle {
543            (
544                TextFont {
545                    font_size: 33.0,
546                    ..default()
547                },
548                TextColor(TEXT_COLOR),
549            )
550        }
551
552        let display_quality = *display_quality;
553        commands.spawn((
554            Node {
555                width: Val::Percent(100.0),
556                height: Val::Percent(100.0),
557                align_items: AlignItems::Center,
558                justify_content: JustifyContent::Center,
559                ..default()
560            },
561            OnDisplaySettingsMenuScreen,
562            children![(
563                Node {
564                    flex_direction: FlexDirection::Column,
565                    align_items: AlignItems::Center,
566                    ..default()
567                },
568                BackgroundColor(CRIMSON.into()),
569                children![
570                    // Create a new `Node`, this time not setting its `flex_direction`. It will
571                    // use the default value, `FlexDirection::Row`, from left to right.
572                    (
573                        Node {
574                            align_items: AlignItems::Center,
575                            ..default()
576                        },
577                        BackgroundColor(CRIMSON.into()),
578                        Children::spawn((
579                            // Display a label for the current setting
580                            Spawn((Text::new("Display Quality"), button_text_style())),
581                            SpawnWith(move |parent: &mut ChildSpawner| {
582                                for quality_setting in [
583                                    DisplayQuality::Low,
584                                    DisplayQuality::Medium,
585                                    DisplayQuality::High,
586                                ] {
587                                    let mut entity = parent.spawn((
588                                        Button,
589                                        Node {
590                                            width: Val::Px(150.0),
591                                            height: Val::Px(65.0),
592                                            ..button_node()
593                                        },
594                                        BackgroundColor(NORMAL_BUTTON),
595                                        quality_setting,
596                                        children![(
597                                            Text::new(format!("{quality_setting:?}")),
598                                            button_text_style(),
599                                        )],
600                                    ));
601                                    if display_quality == quality_setting {
602                                        entity.insert(SelectedOption);
603                                    }
604                                }
605                            })
606                        ))
607                    ),
608                    // Display the back button to return to the settings screen
609                    (
610                        Button,
611                        button_node(),
612                        BackgroundColor(NORMAL_BUTTON),
613                        MenuButtonAction::BackToSettings,
614                        children![(Text::new("Back"), button_text_style())]
615                    )
616                ]
617            )],
618        ));
619    }
620
621    fn sound_settings_menu_setup(mut commands: Commands, volume: Res<Volume>) {
622        let button_node = Node {
623            width: Val::Px(200.0),
624            height: Val::Px(65.0),
625            margin: UiRect::all(Val::Px(20.0)),
626            justify_content: JustifyContent::Center,
627            align_items: AlignItems::Center,
628            ..default()
629        };
630        let button_text_style = (
631            TextFont {
632                font_size: 33.0,
633                ..default()
634            },
635            TextColor(TEXT_COLOR),
636        );
637
638        let volume = *volume;
639        let button_node_clone = button_node.clone();
640        commands.spawn((
641            Node {
642                width: Val::Percent(100.0),
643                height: Val::Percent(100.0),
644                align_items: AlignItems::Center,
645                justify_content: JustifyContent::Center,
646                ..default()
647            },
648            OnSoundSettingsMenuScreen,
649            children![(
650                Node {
651                    flex_direction: FlexDirection::Column,
652                    align_items: AlignItems::Center,
653                    ..default()
654                },
655                BackgroundColor(CRIMSON.into()),
656                children![
657                    (
658                        Node {
659                            align_items: AlignItems::Center,
660                            ..default()
661                        },
662                        BackgroundColor(CRIMSON.into()),
663                        Children::spawn((
664                            Spawn((Text::new("Volume"), button_text_style.clone())),
665                            SpawnWith(move |parent: &mut ChildSpawner| {
666                                for volume_setting in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] {
667                                    let mut entity = parent.spawn((
668                                        Button,
669                                        Node {
670                                            width: Val::Px(30.0),
671                                            height: Val::Px(65.0),
672                                            ..button_node_clone.clone()
673                                        },
674                                        BackgroundColor(NORMAL_BUTTON),
675                                        Volume(volume_setting),
676                                    ));
677                                    if volume == Volume(volume_setting) {
678                                        entity.insert(SelectedOption);
679                                    }
680                                }
681                            })
682                        ))
683                    ),
684                    (
685                        Button,
686                        button_node,
687                        BackgroundColor(NORMAL_BUTTON),
688                        MenuButtonAction::BackToSettings,
689                        children![(Text::new("Back"), button_text_style)]
690                    )
691                ]
692            )],
693        ));
694    }
695
696    fn menu_action(
697        interaction_query: Query<
698            (&Interaction, &MenuButtonAction),
699            (Changed<Interaction>, With<Button>),
700        >,
701        mut app_exit_events: EventWriter<AppExit>,
702        mut menu_state: ResMut<NextState<MenuState>>,
703        mut game_state: ResMut<NextState<GameState>>,
704    ) {
705        for (interaction, menu_button_action) in &interaction_query {
706            if *interaction == Interaction::Pressed {
707                match menu_button_action {
708                    MenuButtonAction::Quit => {
709                        app_exit_events.write(AppExit::Success);
710                    }
711                    MenuButtonAction::Play => {
712                        game_state.set(GameState::Game);
713                        menu_state.set(MenuState::Disabled);
714                    }
715                    MenuButtonAction::Settings => menu_state.set(MenuState::Settings),
716                    MenuButtonAction::SettingsDisplay => {
717                        menu_state.set(MenuState::SettingsDisplay);
718                    }
719                    MenuButtonAction::SettingsSound => {
720                        menu_state.set(MenuState::SettingsSound);
721                    }
722                    MenuButtonAction::BackToMainMenu => menu_state.set(MenuState::Main),
723                    MenuButtonAction::BackToSettings => {
724                        menu_state.set(MenuState::Settings);
725                    }
726                }
727            }
728        }
729    }
examples/testbed/2d.rs (line 58)
51fn switch_scene(
52    keyboard: Res<ButtonInput<KeyCode>>,
53    scene: Res<State<Scene>>,
54    mut next_scene: ResMut<NextState<Scene>>,
55) {
56    if keyboard.just_pressed(KeyCode::Space) {
57        info!("Switching scene");
58        next_scene.set(scene.get().next());
59    }
60}
examples/testbed/3d.rs (line 58)
51fn switch_scene(
52    keyboard: Res<ButtonInput<KeyCode>>,
53    scene: Res<State<Scene>>,
54    mut next_scene: ResMut<NextState<Scene>>,
55) {
56    if keyboard.just_pressed(KeyCode::Space) {
57        info!("Switching scene");
58        next_scene.set(scene.get().next());
59    }
60}
examples/testbed/ui.rs (line 69)
62fn switch_scene(
63    keyboard: Res<ButtonInput<KeyCode>>,
64    scene: Res<State<Scene>>,
65    mut next_scene: ResMut<NextState<Scene>>,
66) {
67    if keyboard.just_pressed(KeyCode::Space) {
68        info!("Switching scene");
69        next_scene.set(scene.get().next());
70    }
71}
examples/math/render_primitives.rs (line 363)
358fn switch_cameras(current: Res<State<CameraActive>>, mut next: ResMut<NextState<CameraActive>>) {
359    let next_state = match current.get() {
360        CameraActive::Dim2 => CameraActive::Dim3,
361        CameraActive::Dim3 => CameraActive::Dim2,
362    };
363    next.set(next_state);
364}
365
366fn setup_text(mut commands: Commands, cameras: Query<(Entity, &Camera)>) {
367    let active_camera = cameras
368        .iter()
369        .find_map(|(entity, camera)| camera.is_active.then_some(entity))
370        .expect("run condition ensures existence");
371    commands.spawn((
372        HeaderNode,
373        Node {
374            justify_self: JustifySelf::Center,
375            top: Val::Px(5.0),
376            ..Default::default()
377        },
378        UiTargetCamera(active_camera),
379        children![(
380            Text::default(),
381            HeaderText,
382            TextLayout::new_with_justify(JustifyText::Center),
383            children![
384                TextSpan::new("Primitive: "),
385                TextSpan(format!("{text}", text = PrimitiveSelected::default())),
386                TextSpan::new("\n\n"),
387                TextSpan::new(
388                    "Press 'C' to switch between 2D and 3D mode\n\
389                    Press 'Up' or 'Down' to switch to the next/previous primitive",
390                ),
391                TextSpan::new("\n\n"),
392                TextSpan::new("(If nothing is displayed, there's no rendering support yet)",),
393            ]
394        )],
395    ));
396}
397
398fn update_text(
399    primitive_state: Res<State<PrimitiveSelected>>,
400    header: Query<Entity, With<HeaderText>>,
401    mut writer: TextUiWriter,
402) {
403    let new_text = format!("{text}", text = primitive_state.get());
404    header.iter().for_each(|header_text| {
405        if let Some(mut text) = writer.get_text(header_text, 2) {
406            (*text).clone_from(&new_text);
407        };
408    });
409}
410
411fn switch_to_next_primitive(
412    current: Res<State<PrimitiveSelected>>,
413    mut next: ResMut<NextState<PrimitiveSelected>>,
414) {
415    let next_state = current.get().next();
416    next.set(next_state);
417}
418
419fn switch_to_previous_primitive(
420    current: Res<State<PrimitiveSelected>>,
421    mut next: ResMut<NextState<PrimitiveSelected>>,
422) {
423    let next_state = current.get().previous();
424    next.set(next_state);
425}
Source

pub fn reset(&mut self)

Remove any pending changes to State<S>

Trait Implementations§

Source§

impl<S> Clone for NextState<S>

Source§

fn clone(&self) -> NextState<S>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S> Debug for NextState<S>

Source§

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

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

impl<S> Default for NextState<S>

Source§

fn default() -> NextState<S>

Returns the “default value” for a type. Read more
Source§

impl<S> Enum for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

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

Returns a reference to the value of the field (in the current variant) with the given name. Read more
Source§

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

Returns a reference to the value of the field (in the current variant) at the given index.
Source§

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

Returns a mutable reference to the value of the field (in the current variant) with the given name. Read more
Source§

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

Returns a mutable reference to the value of the field (in the current variant) at the given index.
Source§

fn index_of(&self, __name_param: &str) -> Option<usize>

Returns the index of the field (in the current variant) with the given name. Read more
Source§

fn name_at(&self, __index_param: usize) -> Option<&str>

Returns the name of the field (in the current variant) with the given index. Read more
Source§

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

Returns an iterator over the values of the current variant’s fields.
Source§

fn field_len(&self) -> usize

Returns the number of fields in the current variant.
Source§

fn variant_name(&self) -> &str

The name of the current variant.
Source§

fn variant_index(&self) -> usize

The index of the current variant.
Source§

fn variant_type(&self) -> VariantType

The type of the current variant.
Source§

fn to_dynamic_enum(&self) -> DynamicEnum

Creates a new DynamicEnum from this enum.
Source§

fn clone_dynamic(&self) -> DynamicEnum

👎Deprecated since 0.16.0: use to_dynamic_enum instead
Source§

fn is_variant(&self, variant_type: VariantType) -> bool

Returns true if the current variant’s type matches the given one.
Source§

fn variant_path(&self) -> String

Returns the full path to the current variant.
Source§

fn get_represented_enum_info(&self) -> Option<&'static EnumInfo>

Will return None if TypeInfo is not available.
Source§

impl<S> FromArg for &'static NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

type This<'from_arg> = &'from_arg NextState<S>

The type to convert into. Read more
Source§

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

Creates an item from an argument. Read more
Source§

impl<S> FromArg for &'static mut NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

type This<'from_arg> = &'from_arg mut NextState<S>

The type to convert into. Read more
Source§

fn from_arg( arg: Arg<'_>, ) -> Result<<&'static mut NextState<S> as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

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

Source§

type This<'from_arg> = NextState<S>

The type to convert into. Read more
Source§

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

Creates an item from an argument. Read more
Source§

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

Source§

fn from_reflect( __param0: &(dyn PartialReflect + 'static), ) -> Option<NextState<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> GetOwnership for &NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl<S> GetOwnership for &mut NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

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

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl<S> GetTypeRegistration for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<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 &NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

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

Converts Self into a Return value.
Source§

impl<S> IntoReturn for &mut NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where &mut NextState<S>: 'into_return,

Converts Self into a Return value.
Source§

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

Source§

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

Converts Self into a Return value.
Source§

impl<S> PartialReflect for NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<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_param: &(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<NextState<S>>) -> ReflectOwned

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

fn try_into_reflect( self: Box<NextState<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<NextState<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_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). 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 clone_value(&self) -> Box<dyn PartialReflect>

👎Deprecated since 0.16.0: to clone reflected values, prefer using reflect_clone. To convert reflected values to dynamic ones, use to_dynamic.
Clones Self into its dynamic representation. 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 is_dynamic(&self) -> bool

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

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

Source§

fn into_any(self: Box<NextState<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<NextState<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> TypePath for NextState<S>

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 NextState<S>
where S: FreelyMutableState + TypePath + FromReflect + MaybeTyped + RegisterForReflection, NextState<S>: Any + Send + Sync,

Source§

fn type_info() -> &'static TypeInfo

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

impl<S> Resource for NextState<S>
where S: FreelyMutableState, NextState<S>: Send + Sync + 'static,

Auto Trait Implementations§

§

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

§

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

§

impl<S> Send for NextState<S>

§

impl<S> Sync for NextState<S>

§

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

§

impl<S> UnwindSafe for NextState<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

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<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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

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,