Skip to main content

ReplayController

Struct ReplayController 

Source
pub struct ReplayController {
    pub state: ReplayState,
    pub config: ReplayConfig,
    /* private fields */
}
Expand description

Replay controller

Orchestrates the replay system, managing state, data feeding, and action handling. This is the main entry point for integrating replay functionality into your application.

Fields§

§state: ReplayState

Replay state

§config: ReplayConfig

Replay configuration

Implementations§

Source§

impl ReplayController

Source

pub fn seek_cutoff(&mut self, time: DateTime<Utc>, clock: &BarClock) -> bool

Seeks to the last source bar completed by an exclusive cutoff. Returns false without changes when the source has no completed bar there. Useful when changing source interval.

Source

pub fn cutoff(&self, clock: &BarClock) -> Option<DateTime<Utc>>

The exclusive cutoff after the current source bar, suitable for Chart::set_replay_time. Pass the source interval’s clock, including its calendar timezone.

Source

pub fn session(&self) -> Option<ReplaySession>

Saves the active cursor for host storage, excluding bars and transient UI state.

Source

pub fn restore_session(&mut self, session: &ReplaySession) -> bool

Restores an exact source timestamp, paused, or returns false without changes when history, symbol or speed is incompatible. Missing history must be fetched by the host; a missing timestamp is never silently replaced with a different session position.

Source§

impl ReplayController

Source

pub fn new(bars: Vec<Bar>, _ts: Vec<DateTime<Utc>>) -> Self

Create a new replay controller with bar data. Timestamps are read from the bars; the separate timestamp argument is retained for source compatibility.

Source

pub fn with_config(self, config: ReplayConfig) -> Self

Create with configuration

Source

pub fn with_symbol(self, symbol: impl Into<String>) -> Self

Set the symbol name

Source

pub fn load_data( &mut self, bars: Vec<Bar>, _ts: Vec<DateTime<Utc>>, symbol: String, )

Load new bar data

During an active replay the position moves to the last bar that opens at or before the current replay time and playback carries on, so a change of interval continues the replay where it was. On a coarser interval the bar that contains the replay time is shown whole; a host that wants it partial passes that bar built from the finer bars. Otherwise the replay starts paused on the first bar.

Source

pub fn unload_data(&mut self)

Unload current data

Source

pub fn has_data(&self) -> bool

Check if data is loaded

Source

pub fn curr_bar(&self) -> Option<&Bar>

Get the current bar

Source

pub fn curr_ts(&self) -> Option<&DateTime<Utc>>

Get the current ts

Source

pub fn visible_bars(&self) -> &[Bar]

Get visible bars up to current position

Source

pub fn visible_ts(&self) -> &[DateTime<Utc>]

Get visible ts up to current position

Source

pub fn bars_in_window(&self, window_size: usize) -> &[Bar]

Get bars in a window around current position

Source

pub fn handle_action(&mut self, action: ReplayAction)

Handle a replay action

Source

pub fn update(&mut self) -> usize

Update state each frame (call in your render loop)

Trait Implementations§

Source§

impl Default for ReplayController

Source§

fn default() -> ReplayController

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