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: ReplayStateReplay state
config: ReplayConfigReplay configuration
Implementations§
Source§impl ReplayController
impl ReplayController
Sourcepub fn seek_cutoff(&mut self, time: DateTime<Utc>, clock: &BarClock) -> bool
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.
Sourcepub fn cutoff(&self, clock: &BarClock) -> Option<DateTime<Utc>>
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.
Sourcepub fn session(&self) -> Option<ReplaySession>
pub fn session(&self) -> Option<ReplaySession>
Saves the active cursor for host storage, excluding bars and transient UI state.
Sourcepub fn restore_session(&mut self, session: &ReplaySession) -> bool
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
impl ReplayController
Sourcepub fn new(bars: Vec<Bar>, _ts: Vec<DateTime<Utc>>) -> Self
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.
Sourcepub fn with_config(self, config: ReplayConfig) -> Self
pub fn with_config(self, config: ReplayConfig) -> Self
Create with configuration
Sourcepub fn with_symbol(self, symbol: impl Into<String>) -> Self
pub fn with_symbol(self, symbol: impl Into<String>) -> Self
Set the symbol name
Sourcepub fn load_data(
&mut self,
bars: Vec<Bar>,
_ts: Vec<DateTime<Utc>>,
symbol: String,
)
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.
Sourcepub fn unload_data(&mut self)
pub fn unload_data(&mut self)
Unload current data
Sourcepub fn visible_bars(&self) -> &[Bar]
pub fn visible_bars(&self) -> &[Bar]
Get visible bars up to current position
Sourcepub fn visible_ts(&self) -> &[DateTime<Utc>]
pub fn visible_ts(&self) -> &[DateTime<Utc>]
Get visible ts up to current position
Sourcepub fn bars_in_window(&self, window_size: usize) -> &[Bar]
pub fn bars_in_window(&self, window_size: usize) -> &[Bar]
Get bars in a window around current position
Sourcepub fn handle_action(&mut self, action: ReplayAction)
pub fn handle_action(&mut self, action: ReplayAction)
Handle a replay action
Trait Implementations§
Source§impl Default for ReplayController
impl Default for ReplayController
Source§fn default() -> ReplayController
fn default() -> ReplayController
Auto Trait Implementations§
impl Freeze for ReplayController
impl RefUnwindSafe for ReplayController
impl Send for ReplayController
impl Sync for ReplayController
impl Unpin for ReplayController
impl UnsafeUnpin for ReplayController
impl UnwindSafe for ReplayController
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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