Skip to main content

DiscontinuousTransitioner

Struct DiscontinuousTransitioner 

Source
pub struct DiscontinuousTransitioner {
    state_buffer: Vec<Arc<IterationState>>,
    time_per_flomap: f64,
    current_index: usize,
}
Expand description

A transitioner that handles discontinuous transitions between flow-map states.

Each IterationState in state_buffer represents a flow-map state, and consecutive states are separated by a fixed duration time_per_flomap.

§Behavior

  • The transitioner does not maintain an internal time counter; calling advance or advance_arc with the same current_time multiple times are idempotent and always returns the correct state corresponding to current_time.
  • Delta time argument is therefore not used
  • Transitions are discontinuous: as current_time crosses multiples of time_per_flomap, current_index jumps directly to the correct state in state_buffer.
  • Iteration is cyclic: when the current_index reaches the last state, it wraps around to index 0. For example, with 15 states, iteration goes: 14 -> 0 -> 1 -> ....
  • current_index always points to the active flow-map state based on current_time.

§Fields

  • state_buffer — A Vec<Arc<IterationState>> containing all flow-map states.
  • time_per_flomap — Duration of each flow-map in seconds (or any consistent time unit).
  • current_index — The index of the currently active flow-map state in state_buffer.

§Example

let transitioner = DiscontinuousTransitioner {
    state_buffer: vec![Arc::new(state1), Arc::new(state2), Arc::new(state3)],
    time_per_flomap: 0.5,
    current_index: 0,
};

// current_time = 1.3 -> index = 2 (3rd state)
let state = transitioner.advance(1.3, 0.1);

// current_time = 1.6 -> cycles back to index 0 (if 3 states)
let state = transitioner.advance(1.6, 0.1);

Fields§

§state_buffer: Vec<Arc<IterationState>>§time_per_flomap: f64§current_index: usize

Implementations§

Source§

impl DiscontinuousTransitioner

Source

fn index_for_time(&self, t: f64) -> usize

Source

fn get_index_and_state( &mut self, current_time: f64, ) -> (usize, &Arc<IterationState>)

Source

fn get_state(&mut self, current_time: f64) -> &Arc<IterationState>

Source

pub fn advance_mut( &mut self, state: &mut Arc<IterationState>, current_time: f64, _time_step: f64, ) -> bool

Trait Implementations§

Source§

impl FlowMapTransitioner for DiscontinuousTransitioner

Source§

fn advance(&mut self, current_time: f64, _time_step: f64) -> &IterationState

Advances the internal state according to current_time and time_step, and returns a borrowed reference to the active IterationState. Read more
Source§

fn advance_arc( &mut self, current_time: f64, _time_step: f64, ) -> Arc<IterationState>

Same as [advance], but returns an owned Arc<IterationState>. Read more
Source§

fn need_advance(&self, current_time: f64, _time_step: f64) -> bool

Returns true if the flow-map index should advance when evaluating the given current_time and time_step. Read more
Source§

fn size(&self) -> usize

Returns the number of flow-map states stored in this transitioner.
Source§

fn get_current_arc(&self) -> Arc<IterationState>

Returns the current state as an owned Arc<IterationState>.
Source§

fn get_current(&self) -> &IterationState

Returns the current state as a borrowed reference.
Source§

fn get_at(&self, idx: usize) -> Option<Arc<IterationState>>

Retrieves the state at the given buffer index as an owned Arc. Read more
Source§

fn new(time_per_flomap: f64, buffer: FlowMapBuffer) -> Self

Constructs a new transitioner from the duration of each flow-map (time_per_flomap) and a validated FlowMapBuffer. Read more
Source§

fn from_case(root: &str, case: &CMCase) -> Result<Self, DataError>
where Self: Sized,

Constructs a transitioner by loading flow-map descriptors from disk using the provided case definition. 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
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> Same for T

Source§

type Output = T

Should always be Self
§

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

§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

fn from_subset(element: &SS) -> SP

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