Skip to main content

ReplayState

Struct ReplayState 

Source
pub struct ReplayState {
Show 13 fields pub playback_state: PlaybackState, pub speed: ReplaySpeed, pub curr_bar: usize, pub total_bars: usize, pub visible_bars: usize, pub start_date: Option<DateTime<Utc>>, pub end_date: Option<DateTime<Utc>>, pub curr_date: Option<DateTime<Utc>>, pub symbol: Option<String>, pub speed_dropdown_open: bool, pub date_picker_open: bool, pub settings_open: bool, pub markers: Vec<ReplayMarker>, /* private fields */
}
Expand description

Main replay state

Fields§

§playback_state: PlaybackState

Current playback state

§speed: ReplaySpeed

Current playback speed

§curr_bar: usize

Current bar index (0-based)

§total_bars: usize

Total number of bars available

§visible_bars: usize

Visible bar count (how many bars to show on chart)

§start_date: Option<DateTime<Utc>>

Start date of replay data

§end_date: Option<DateTime<Utc>>

End date of replay data

§curr_date: Option<DateTime<Utc>>

Current date/time at playback position

§symbol: Option<String>

Symbol being replayed

§speed_dropdown_open: bool

Whether speed dropdown is open

§date_picker_open: bool

Whether date picker is open

§settings_open: bool

Whether settings panel is open

§markers: Vec<ReplayMarker>

User-placed markers

Implementations§

Source§

impl ReplayState

Source

pub fn new() -> Self

Create new replay state

Source

pub fn init( &mut self, total_bars: usize, start_date: DateTime<Utc>, end_date: DateTime<Utc>, symbol: String, )

Initialize replay with data params

Source

pub fn set_bar_duration(&mut self, seconds: f64)

Set the bar duration (time between bars at 1x speed)

Source

pub fn is_active(&self) -> bool

Check if replay mode is active

Source

pub fn is_playing(&self) -> bool

Check if currently playing

Source

pub fn progress(&self) -> f32

Get progress as percentage (0.0 - 1.0)

Source

pub fn remaining_bars(&self) -> usize

Get remaining bars

Source

pub fn at_end(&self) -> bool

Check if at the end

Source

pub fn at_start(&self) -> bool

Check if at the beginning

Source

pub fn play(&mut self)

Start playing

Source

pub fn pause(&mut self)

Pause playback

Source

pub fn toggle_play_pause(&mut self)

Toggle play/pause

Source

pub fn stop(&mut self)

Stop and exit replay mode

Source

pub fn reset(&mut self)

Reset to beginning without exiting replay mode

Source

pub fn enter_replay_mode(&mut self)

Enter replay mode

Source

pub fn exit_replay_mode(&mut self)

Exit replay mode

Source

pub fn step_forward(&mut self)

Step forward one bar

Source

pub fn step_backward(&mut self)

Step backward one bar

Source

pub fn jump_to_bar(&mut self, bar: usize)

Jump to specific bar

Source

pub fn jump_to_percent(&mut self, percent: f32)

Jump to percentage position

Source

pub fn set_speed(&mut self, speed: ReplaySpeed)

Set playback speed

Source

pub fn speed_up(&mut self)

Increase speed

Source

pub fn slow_down(&mut self)

Decrease speed

Source

pub fn add_marker(&mut self, label: Option<String>, color: Option<[u8; 4]>)

Add a marker at current position

Source

pub fn remove_marker(&mut self, bar_idx: usize)

Remove marker at bar index

Source

pub fn clear_markers(&mut self)

Clear all markers

Source

pub fn visible_markers( &self, start_bar: usize, end_bar: usize, ) -> Vec<&ReplayMarker>

Get markers in visible range

Source

pub fn update(&mut self) -> usize

Update playback state. Call this each frame. Returns the number of bars actually advanced (usually 0 or 1).

Source

pub fn update_curr_date(&mut self, bar_ts: &[DateTime<Utc>])

Update current date based on bar index

Source

pub fn sync_from( &mut self, active: bool, playing: bool, current_bar: usize, total_bars: usize, speed: ReplaySpeed, )

Sync replay state from external values.

active / playing drive the playback state machine, current_bar / total_bars sync position, and speed sets playback rate.

Trait Implementations§

Source§

impl Clone for ReplayState

Source§

fn clone(&self) -> ReplayState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ReplayState

Source§

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

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

impl Default for ReplayState

Source§

fn default() -> Self

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

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> IntoEither for T

Source§

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

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

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

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

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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