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,
impl<S> State<S>where
S: States,
Sourcepub fn new(state: S) -> State<S>
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>
.
Sourcepub fn get(&self) -> &S
pub fn get(&self) -> &S
Get the current state.
Examples found in repository?
More examples
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(®ULAR_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}
Additional examples can be found in:
Trait Implementations§
Source§impl<S> FromReflect for State<S>
impl<S> FromReflect for State<S>
Source§fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<State<S>>
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>>
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 moreSource§impl<S> GetOwnership for State<S>
impl<S> GetOwnership for State<S>
Source§impl<S> GetTypeRegistration for State<S>
impl<S> GetTypeRegistration for State<S>
Source§fn get_type_registration() -> TypeRegistration
fn get_type_registration() -> TypeRegistration
Returns the default
TypeRegistration
for this type.Source§fn register_type_dependencies(registry: &mut TypeRegistry)
fn register_type_dependencies(registry: &mut TypeRegistry)
Registers other types needed by this type. Read more
Source§impl<S> IntoReturn for State<S>
impl<S> IntoReturn for State<S>
Source§impl<S> PartialReflect for State<S>
impl<S> PartialReflect for State<S>
Source§fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
Source§fn try_apply(
&mut self,
value: &(dyn PartialReflect + 'static),
) -> Result<(), ApplyError>
fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>
Source§fn reflect_kind(&self) -> ReflectKind
fn reflect_kind(&self) -> ReflectKind
Returns a zero-sized enumeration of “kinds” of type. Read more
Source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
Returns an immutable enumeration of “kinds” of type. Read more
Source§fn reflect_mut(&mut self) -> ReflectMut<'_>
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
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>>
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)>
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)>
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>
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)
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)
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>
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>
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>
fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
Attempts to clone
Self
using reflection. Read moreSource§fn apply(&mut self, value: &(dyn PartialReflect + 'static))
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>
fn to_dynamic(&self) -> Box<dyn PartialReflect>
Source§fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
For a type implementing
PartialReflect
, combines reflect_clone
and
take
in a useful fashion, automatically constructing an appropriate
ReflectCloneError
if the downcast fails. Read moreSource§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
Returns a hash of the value (which includes the type). Read more
Source§fn is_dynamic(&self) -> bool
fn is_dynamic(&self) -> bool
Indicates whether or not this type is a dynamic type. Read more
Source§impl<S> Reflect for State<S>
impl<S> Reflect for State<S>
Source§fn into_any(self: Box<State<S>>) -> Box<dyn Any>
fn into_any(self: Box<State<S>>) -> Box<dyn Any>
Returns the value as a
Box<dyn Any>
. Read moreSource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Returns the value as a
&mut dyn Any
. Read moreSource§fn into_reflect(self: Box<State<S>>) -> Box<dyn Reflect>
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)
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)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
Casts this type to a mutable, fully-reflected value.
Source§impl<S> TupleStruct for State<S>
impl<S> TupleStruct for State<S>
Source§fn field(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>
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)>
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 iter_fields(&self) -> TupleStructFieldIter<'_> ⓘ
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
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>
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>
impl<S> TypePath for State<S>
Source§fn type_path() -> &'static str
fn type_path() -> &'static str
Returns the fully qualified path of the underlying type. Read more
Source§fn short_type_path() -> &'static str
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>
fn type_ident() -> Option<&'static str>
Source§fn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
impl<S> Resource for State<S>
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, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, C, D> Curve<T> for D
impl<T, C, D> Curve<T> for D
Source§fn sample_unchecked(&self, t: f32) -> T
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 moreSource§fn sample(&self, t: f32) -> Option<T>
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
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 Cwhere
C: Curve<T>,
impl<C, T> CurveExt<T> for Cwhere
C: Curve<T>,
Source§fn sample_iter(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = Option<T>>
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 moreSource§fn sample_iter_unchecked(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = T>
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 moreSource§fn sample_iter_clamped(
&self,
iter: impl IntoIterator<Item = f32>,
) -> impl Iterator<Item = T>
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 moreSource§fn map<S, F>(self, f: F) -> MapCurve<T, S, Self, F>where
F: Fn(T) -> S,
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>
fn reparametrize<F>(self, domain: Interval, f: F) -> ReparamCurve<T, Self, F>
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 moreSource§fn reparametrize_linear(
self,
domain: Interval,
) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>
fn reparametrize_linear( self, domain: Interval, ) -> Result<LinearReparamCurve<T, Self>, LinearReparamError>
Source§fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>
fn reparametrize_by_curve<C>(self, other: C) -> CurveReparamCurve<T, Self, C>
Source§fn graph(self) -> GraphCurve<T, Self>
fn graph(self) -> GraphCurve<T, Self>
Source§fn zip<S, C>(
self,
other: C,
) -> Result<ZipCurve<T, S, Self, C>, InvalidIntervalError>where
C: Curve<S>,
fn zip<S, C>(
self,
other: C,
) -> Result<ZipCurve<T, S, Self, C>, InvalidIntervalError>where
C: Curve<S>,
Source§fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>where
C: Curve<T>,
fn chain<C>(self, other: C) -> Result<ChainCurve<T, Self, C>, ChainError>where
C: Curve<T>,
Source§fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>
fn reverse(self) -> Result<ReverseCurve<T, Self>, ReverseError>
Source§fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>
fn repeat(self, count: usize) -> Result<RepeatCurve<T, Self>, RepeatError>
Source§fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>
fn forever(self) -> Result<ForeverCurve<T, Self>, RepeatError>
Source§fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>
fn ping_pong(self) -> Result<PingPongCurve<T, Self>, PingPongError>
Source§fn chain_continue<C>(
self,
other: C,
) -> Result<ContinuationCurve<T, Self, C>, ChainError>where
T: VectorSpace,
C: Curve<T>,
fn chain_continue<C>(
self,
other: C,
) -> Result<ContinuationCurve<T, Self, C>, ChainError>where
T: VectorSpace,
C: Curve<T>,
Source§fn samples(
&self,
samples: usize,
) -> Result<impl Iterator<Item = T>, ResamplingError>
fn samples( &self, samples: usize, ) -> Result<impl Iterator<Item = T>, ResamplingError>
Extract an iterator over evenly-spaced samples from this curve. Read more
Source§impl<C, T> CurveResampleExt<T> for C
impl<C, T> CurveResampleExt<T> for C
Source§fn resample<I>(
&self,
segments: usize,
interpolation: I,
) -> Result<SampleCurve<T, I>, ResamplingError>
fn resample<I>( &self, segments: usize, interpolation: I, ) -> Result<SampleCurve<T, I>, ResamplingError>
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 moreSource§fn resample_auto(
&self,
segments: usize,
) -> Result<SampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
fn resample_auto(
&self,
segments: usize,
) -> Result<SampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
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 moreSource§fn resample_uneven<I>(
&self,
sample_times: impl IntoIterator<Item = f32>,
interpolation: I,
) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
fn resample_uneven<I>( &self, sample_times: impl IntoIterator<Item = f32>, interpolation: I, ) -> Result<UnevenSampleCurve<T, I>, ResamplingError>
Source§fn resample_uneven_auto(
&self,
sample_times: impl IntoIterator<Item = f32>,
) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
fn resample_uneven_auto(
&self,
sample_times: impl IntoIterator<Item = f32>,
) -> Result<UnevenSampleAutoCurve<T>, ResamplingError>where
T: StableInterpolate,
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 moreSource§impl<T, C> CurveWithDerivative<T> for Cwhere
T: HasTangent,
C: SampleDerivative<T>,
impl<T, C> CurveWithDerivative<T> for Cwhere
T: HasTangent,
C: SampleDerivative<T>,
Source§fn with_derivative(self) -> SampleDerivativeWrapper<C>
fn with_derivative(self) -> SampleDerivativeWrapper<C>
This curve, but with its first derivative included in sampling. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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 Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DynamicTypePath for Twhere
T: TypePath,
impl<T> DynamicTypePath for Twhere
T: TypePath,
Source§fn reflect_type_path(&self) -> &str
fn reflect_type_path(&self) -> &str
See
TypePath::type_path
.Source§fn reflect_short_type_path(&self) -> &str
fn reflect_short_type_path(&self) -> &str
Source§fn reflect_type_ident(&self) -> Option<&str>
fn reflect_type_ident(&self) -> Option<&str>
See
TypePath::type_ident
.Source§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
See
TypePath::crate_name
.Source§fn reflect_module_path(&self) -> Option<&str>
fn reflect_module_path(&self) -> Option<&str>
Source§impl<T> DynamicTyped for Twhere
T: Typed,
impl<T> DynamicTyped for Twhere
T: Typed,
Source§fn reflect_type_info(&self) -> &'static TypeInfo
fn reflect_type_info(&self) -> &'static TypeInfo
See
Typed::type_info
.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
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,
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,
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,
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,
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,
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,
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,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> GetPath for T
impl<T> GetPath for T
Source§fn reflect_path<'p>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
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 moreSource§fn reflect_path_mut<'p>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
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 moreSource§fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
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 moreSource§fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
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 moreSource§impl<S> GetTupleStructField for Swhere
S: TupleStruct,
impl<S> GetTupleStructField for Swhere
S: TupleStruct,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
Source§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
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) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, C, D> SampleDerivative<T> for D
impl<T, C, D> SampleDerivative<T> for D
Source§fn sample_with_derivative_unchecked(&self, t: f32) -> WithDerivative<T>
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 moreSource§fn sample_with_derivative(&self, t: f32) -> Option<WithDerivative<T>>
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>
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
impl<T> Source for T
Source§type Slice<'a> = <<T as Deref>::Target as Source>::Slice<'a>
where
T: 'a
type Slice<'a> = <<T as Deref>::Target as Source>::Slice<'a> where T: 'a
A type this
Source
can be sliced into.Source§fn read<'a, Chunk>(&'a self, offset: usize) -> Option<Chunk>where
Chunk: Chunk<'a>,
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 moreSource§unsafe fn read_byte_unchecked(&self, offset: usize) -> u8
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<'_>>
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 moreSource§unsafe fn slice_unchecked(
&self,
range: Range<usize>,
) -> <T as Source>::Slice<'_>
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 moreSource§fn is_boundary(&self, index: usize) -> bool
fn is_boundary(&self, index: usize) -> bool
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
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
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
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
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
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
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
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.