Skip to main content

TimelineCursor

Struct TimelineCursor 

Source
pub struct TimelineCursor { /* private fields */ }
Expand description

The scrub position over a validated LoadedBundle: the current integer step plus one per-table index for “as of position” slicing (docs/01-domain-model.md §10).

The cursor is Copy and holds only indices — it never borrows or copies a table, so it is cheap to snapshot (the incremental_equals_arbitrary property compares two cursors by value). Every query takes the same LoadedBundle it was constructed from and returns borrowed rows; passing a different bundle yields meaningless indices (a caller contract, not re-validated).

position and end_step are read-only ACCESSORS (a screen renders “step position of end_step”); the fields are private so the cursor can only move through seek, which re-establishes the index invariant — a desynced direct write is unrepresentable.

Implementations§

Source§

impl TimelineCursor

Source

pub fn end_step(&self) -> u32

The last step of the tape (the first is always 0).

Source

pub fn position(&self) -> u32

The current scrub step — always in 0..=end_step after any seek.

Source

pub fn new(bundle: &LoadedBundle) -> Self

Build a cursor over bundle at position = 0 with each index resolved by binary search (docs/01-domain-model.md §10).

end_step is N - 1 for an N-step run and 0 for an empty run — relying on the #32 guarantee that equity_curve is one row per step over the contiguous domain 0..N (module docs, reliance 1).

Source

pub const fn is_at_start(self) -> bool

Whether the cursor is at the first step (position == 0).

Source

pub const fn is_at_end(self) -> bool

Whether the cursor is at the last step (position == end_step) — the point at which playback stops.

Source

pub fn seek(&mut self, to: SeekTo, bundle: &LoadedBundle)

Move the cursor by to, re-establishing every per-table index for the new clamped position (docs/04-replay-mode.md §4).

  • SeekTo::StepBy walks each index incrementally from its current value (O(rows moved), never a rescan) — the O(1) play-head / ←/→ path;
  • SeekTo::Step resolves each index by binary search (O(log n)) — the Home/End/large-jump path.

The target position is clamped to 0..=end_step with checked arithmetic, so a step past either edge (including a playback tick at the end) is a no-op clamp, never an overflow or a wrap. Both paths land on the same index invariant, so the result depends only on the final position.

Source

pub fn advance_playback(&mut self, playback: Playback, bundle: &LoadedBundle)

Apply one scheduled playback advance: seek forward by playback’s quantum (Playback::tick_seek), or leave the cursor unchanged when paused (docs/04-replay-mode.md §4). The forward step is a SeekTo::StepBy, so the seek clamps at end_step — playback stops at the end of the tape and never wraps. This is the model of the quantum and the stop-at-end rule; the tick cadence that calls it is the app’s (issue #34).

Source

pub fn visible_equity<'b>(&self, bundle: &'b LoadedBundle) -> &'b [EquityPoint]

The equity curve up to and including the head step — the drawdown-shaded series the equity screen renders (docs/04-replay-mode.md §4).

Source

pub fn visible_greeks<'b>( &self, bundle: &'b LoadedBundle, ) -> &'b [GreeksAttribution]

The per-step P&L attribution rows with step <= position — the as-of attribution slice up to and including the head step (docs/04-replay-mode.md §4). ChainView never recomputes or sums the decomposition: the replay screen renders the head-step row (head_greeks) as authored, so this full slice is currently unused by the screen — it is retained for the deferred attribution-history / #49 payoff work.

Source

pub fn visible_fills<'b>(&self, bundle: &'b LoadedBundle) -> &'b [Fill]

Every fill with step <= position — the drill-down history up to the head.

Source

pub fn visible_positions<'b>( &self, bundle: &'b LoadedBundle, ) -> &'b [PositionRow]

Every positions row with step <= position, terminal rows included — the raw as-of window. open_positions is the filtered, post-fill open set most callers want.

Source

pub fn head_equity<'b>( &self, bundle: &'b LoadedBundle, ) -> Option<&'b EquityPoint>

The equity_curve row at the head step (step == position), or None for an empty run. Relies on reliance 1: the last visible equity row is the head-step row.

Source

pub fn head_greeks<'b>( &self, bundle: &'b LoadedBundle, ) -> Option<&'b GreeksAttribution>

The greeks_attribution row at the head step (step == position), or None for an empty run. Relies on reliance 1.

Source

pub fn head_fills<'b>(&self, bundle: &'b LoadedBundle) -> &'b [Fill]

The fill(s) at exactly the head step (step == position) — the rows a drill-down highlights under the scrub head. Empty when no fill landed on the head step. A realistic order that walked several price levels appears as several rows here.

Source

pub fn open_positions<'b>( &self, bundle: &'b LoadedBundle, ) -> Vec<&'b PositionRow>

The post-fill open-position set at the head step (docs/04-replay-mode.md §4): the latest non-terminal positions row per position_id with step <= position, excluding any position_id whose terminal (exit_reason-bearing) row is at step <= position.

A leg closed at or before the cursor is not shown open; an opening and a closing row at the same step resolve deterministically (the terminal row wins the exclusion); a leg with open_at_end = true and no terminal row stays open through end_step. This is the single algorithm the drill-down and the deferred payoff (#49) both read, so the two screens can never disagree.

The result is ordered by position_id (deterministic) and borrows into the bundle. It is O(k log k) in the k visible position rows, not on the draw path — call it on a seek, not per frame. Relies on reliance 4 (stable position_id, positive quantity).

Trait Implementations§

Source§

impl Clone for TimelineCursor

Source§

fn clone(&self) -> TimelineCursor

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 Copy for TimelineCursor

Source§

impl Debug for TimelineCursor

Source§

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

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

impl Eq for TimelineCursor

Source§

impl PartialEq for TimelineCursor

Source§

fn eq(&self, other: &TimelineCursor) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TimelineCursor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more