Skip to main content

FixedRateSchedule

Struct FixedRateSchedule 

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

Per-agent fixed-rate sample schedule.

See the module docs for what it is for and what it guarantees.

Implementations§

Source§

impl FixedRateSchedule

Source

pub fn new( config: FixedRateScheduleConfig, phase_offset_seconds: f64, ) -> Result<Self, FixedRateScheduleConfigError>

A schedule at simulation time zero, sampling every config.interval_seconds starting at phase_offset_seconds.

Giving each agent a different phase in [0, interval) spreads their samples across the interval instead of stacking them on one tick. A phase of zero first samples one whole interval in, not at time zero, so a freshly built agent does not sample before anything has happened.

§Errors

InvalidInterval if the interval is not valid, and InvalidPhaseOffset if the phase is not finite or falls outside [0, interval).

Source

pub fn phase_offset_seconds(&self) -> f64

The phase this schedule was built with.

Source

pub fn simulation_time_seconds(&self) -> f64

Simulation time this schedule has been advanced or skipped to.

Source

pub fn skip_elapsed( &mut self, elapsed_seconds: f64, ) -> Result<(), FixedRateScheduleAdvanceError>

Advances the local clock without emitting samples for unavailable time.

The next sample remains on the configured phase — exactly the one a schedule advanced through the same time would reach next — while its elapsed baseline starts at the skipped endpoint, so sensory state cannot replay historical samples when an agent resumes.

§Errors

InvalidElapsed, leaving the schedule untouched, if elapsed_seconds is negative or not finite, if the time it reaches is not finite, or if the next sample after it is past MAX_SAMPLE_INDEX or within BOUNDARY_TOLERANCE_SCALE of the skip’s end — an interval too small for the time reached to tell one sample from the next.

Source

pub fn advance( &mut self, elapsed_seconds: f64, emit: impl FnMut(FixedRateSample), ) -> Result<(), FixedRateScheduleAdvanceError>

Invokes emit once for every sample due in this elapsed-time update, in increasing scheduled time.

A sample is due when it is at or before the update’s end, or within BOUNDARY_TOLERANCE_SCALE of it; see the module docs. An update spanning several intervals emits every sample in it — none are dropped or merged.

§Errors

InvalidElapsed, leaving the schedule untouched and emitting nothing, if elapsed_seconds is negative or not finite, or if the time it reaches is not finite.

Source

pub fn next_sample_time_seconds(&self) -> f64

When the next sample not yet emitted or skipped is scheduled, on the schedule’s own clock — the scheduled_simulation_time_seconds the next advance that reaches it will emit first.

A read: nothing is consumed, so a caller deciding how far to step before an agent next samples asks this rather than advancing a copy of the schedule through every sample of the interval. It is always after simulation_time_seconds by more than the boundary tolerance — advance stops only once the next sample is that far past its end, and skip_elapsed refuses a skip that would leave one due — so subtracting the two is how far ahead the next sample falls.

Trait Implementations§

Source§

impl Clone for FixedRateSchedule

Source§

fn clone(&self) -> Self

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 FixedRateSchedule

Source§

impl Debug for FixedRateSchedule

Source§

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

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

impl Default for FixedRateSchedule

Source§

fn default() -> Self

FixedRateScheduleConfig::default with no phase offset.

Source§

impl PartialEq for FixedRateSchedule

Source§

fn eq(&self, other: &Self) -> 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 FixedRateSchedule

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