Skip to main content

Callbacks

Struct Callbacks 

Source
pub struct Callbacks<A> { /* private fields */ }
Expand description

An animation wrapper that emits events at milestones.

Wraps any Animation and queues AnimationEvents during tick(). Call drain_events to retrieve and clear them.

Implementations§

Source§

impl<A: Animation> Callbacks<A>

Source

pub fn new(inner: A) -> Self

Wrap an animation with callback tracking.

Source

pub fn on_start(self) -> Self

Enable the Started event (builder pattern).

Source

pub fn on_complete(self) -> Self

Enable the Completed event (builder pattern).

Source

pub fn at_progress(self, threshold: f32) -> Self

Add a progress threshold event (builder pattern).

Fires when the animation’s value crosses threshold (clamped to [0.0, 1.0]).

Source

pub fn inner(&self) -> &A

Access the inner animation.

Source

pub fn inner_mut(&mut self) -> &mut A

Mutable access to the inner animation.

Source

pub fn drain_events(&mut self) -> Vec<AnimationEvent>

Drain all pending events. Clears the event queue.

Source

pub fn pending_event_count(&self) -> usize

Number of pending events.

Trait Implementations§

Source§

impl<A: Animation> Animation for Callbacks<A>

Source§

fn tick(&mut self, dt: Duration)

Advance the animation by dt.
Source§

fn is_complete(&self) -> bool

Whether the animation has reached its end.
Source§

fn value(&self) -> f32

Current output value, clamped to [0.0, 1.0].
Source§

fn reset(&mut self)

Reset the animation to its initial state.
Source§

fn overshoot(&self) -> Duration

Time elapsed past completion. Used by composition types to forward remaining time (e.g., Sequence forwards overshoot from first to second). Returns Duration::ZERO for animations that never complete.
Source§

impl<A: Debug> Debug for Callbacks<A>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A> Freeze for Callbacks<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for Callbacks<A>
where A: RefUnwindSafe,

§

impl<A> Send for Callbacks<A>
where A: Send,

§

impl<A> Sync for Callbacks<A>
where A: Sync,

§

impl<A> Unpin for Callbacks<A>
where A: Unpin,

§

impl<A> UnsafeUnpin for Callbacks<A>
where A: UnsafeUnpin,

§

impl<A> UnwindSafe for Callbacks<A>
where A: 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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.