Trait conciliator::spin::Animate
source · pub trait Animate {
type State: Default + Send;
// Required methods
fn step(&self, state: &mut Self::State, buf: &mut Buffer) -> Duration;
fn finish(&self, state: Self::State, buf: &mut Buffer);
}
Expand description
Define a custom animation
This uses a separate mutable State
to allow defining animations as constants.
Make sure that every “frame” or step of the animation has the same width!
Otherwise, the animation will overlap with the message or previous frames will not be overwritten completely.
Note that the width is not strictly just the amount of characters, because the color codes and such are also emitted as characters – because the terminal doesn’t print these, you don’t have to make sure you emit the same amount of color codes in every frame.
Just make sure the amount of characters that actually get printed stays the same.