Trait chime::Flux

source ·
pub trait Flux {
    type Moment: Moment<Flux = Self>;
    type Kind: FluxKind;

    // Required methods
    fn base_value(&self) -> <Self::Kind as FluxKind>::Value;
    fn base_time(&self) -> Time;
    fn change<'a>(
        &self,
        accum: <Self::Kind as FluxKind>::Accum<'a>
    ) -> <Self::Kind as FluxKind>::OutAccum<'a>;
    fn to_moment(self, time: Time) -> Self::Moment;

    // Provided methods
    fn set_moment(&mut self, time: Time, moment: Self::Moment)
       where Self: Sized { ... }
    fn at(&self, time: Time) -> MomentRef<'_, Self::Moment>
       where Self: Clone { ... }
    fn at_mut(&mut self, time: Time) -> MomentRefMut<'_, Self::Moment>
       where Self: Clone { ... }
    fn value(&self, time: Time) -> <Self::Kind as FluxKind>::Value { ... }
    fn poly(
        &self,
        time: Time
    ) -> Poly<Self::Kind, <Self::Moment as Moment>::Value> { ... }
    fn when<T>(
        &self,
        order: Ordering,
        other: &T
    ) -> TimeRanges<impl TimeRangeIter> 
       where T: Flux,
             Poly<Self::Kind, <Self::Moment as Moment>::Value>: When<T::Kind> { ... }
    fn when_eq<T>(&self, other: &T) -> TimeRanges<impl TimeRangeIter> 
       where T: Flux,
             Poly<Self::Kind, <Self::Moment as Moment>::Value>: WhenEq<T::Kind> { ... }
}
Expand description

The continuous interface for a value that changes over time.

Required Associated Types§

source

type Moment: Moment<Flux = Self>

source

type Kind: FluxKind

The kind of change over time.

Required Methods§

source

fn base_value(&self) -> <Self::Kind as FluxKind>::Value

An evaluation of this flux at some point in time.

source

fn base_time(&self) -> Time

The time of Flux::base_value.

source

fn change<'a>( &self, accum: <Self::Kind as FluxKind>::Accum<'a> ) -> <Self::Kind as FluxKind>::OutAccum<'a>

Accumulates change over time.

source

fn to_moment(self, time: Time) -> Self::Moment

A moment in the timeline.

Provided Methods§

source

fn set_moment(&mut self, time: Time, moment: Self::Moment)
where Self: Sized,

Sets a moment in the timeline (affects all moments).

source

fn at(&self, time: Time) -> MomentRef<'_, Self::Moment>
where Self: Clone,

A reference to a moment in the timeline.

source

fn at_mut(&mut self, time: Time) -> MomentRefMut<'_, Self::Moment>
where Self: Clone,

A unique, mutable reference to a moment in the timeline.

let mut moment = self.at_mut(time);
// modifications

equivalent to:

let mut moment = self.at(time);
// modifications
self.set_moment(time, moment);
source

fn value(&self, time: Time) -> <Self::Kind as FluxKind>::Value

A point in the timeline.

self.value(self.base_time()) == self.base_value()

source

fn poly(&self, time: Time) -> Poly<Self::Kind, <Self::Moment as Moment>::Value>

A polynomial description of this flux at the given time.

source

fn when<T>(&self, order: Ordering, other: &T) -> TimeRanges<impl TimeRangeIter>
where T: Flux, Poly<Self::Kind, <Self::Moment as Moment>::Value>: When<T::Kind>,

Ranges when this is above/below/equal to another flux.

source

fn when_eq<T>(&self, other: &T) -> TimeRanges<impl TimeRangeIter>
where T: Flux, Poly<Self::Kind, <Self::Moment as Moment>::Value>: WhenEq<T::Kind>,

Times when this is equal to another flux.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T: Flux> Flux for Vec<T>
where T::Kind: for<'a> FluxKind<Accum<'a> = <T::Kind as FluxKind>::OutAccum<'a>>, Vec<T::Moment>: Moment<Flux = Vec<T>>,

§

type Moment = Vec<<T as Flux>::Moment>

§

type Kind = <T as Flux>::Kind

source§

fn base_value(&self) -> <Self::Kind as FluxKind>::Value

source§

fn base_time(&self) -> Time

source§

fn change<'a>( &self, changes: <Self::Kind as FluxKind>::Accum<'a> ) -> <Self::Kind as FluxKind>::OutAccum<'a>

source§

fn to_moment(self, time: Time) -> Self::Moment

Implementors§

source§

impl<T: Linear> Flux for T

§

type Moment = T

§

type Kind = Constant<T>

source§

impl<T: Flux> Flux for Change<T>

§

type Moment = Change<<T as Flux>::Moment>

§

type Kind = <T as Flux>::Kind

source§

impl<T: InnerFlux> Flux for FluxValue<T>
where T::Moment: Moment<Flux = Self>,

§

type Moment = <T as InnerFlux>::Moment

§

type Kind = <T as InnerFlux>::Kind