Skip to main content

Signal

Trait Signal 

Source
pub trait Signal<Value>: Send + Sync {
    // Required method
    fn sample(&self, time: Time) -> Value;

    // Provided methods
    fn sample_at(&self, elapsed: Duration) -> Value { ... }
    fn map<Output, Function>(
        self,
        function: Function,
    ) -> Map<Self, Function, Value>
       where Self: Sized,
             Function: Fn(Value) -> Output + Send + Sync { ... }
    fn zip<OtherValue, Other>(self, other: Other) -> Zip<Self, Other>
       where Self: Sized,
             Other: Signal<OtherValue> { ... }
    fn boxed(self) -> Arc<dyn Signal<Value>> ⓘ
       where Self: Sized + 'static { ... }
}
Expand description

A thread-safe, randomly addressable signal of values over signed local time.

A signal has no end: it may be sampled at any signed time. Sampling must not depend on earlier calls. Signals with a known end implement FiniteAnimation, which owns the duration-aware combinators.

Required Methods§

Source

fn sample(&self, time: Time) -> Value

Samples without advancing a clock or changing playback state.

Provided Methods§

Source

fn sample_at(&self, elapsed: Duration) -> Value

Samples elapsed after the time origin, shorthand for sample(elapsed.after_origin()).

Panics if elapsed is beyond the representable time range, like Duration::after_origin.

Source

fn map<Output, Function>(self, function: Function) -> Map<Self, Function, Value>
where Self: Sized, Function: Fn(Value) -> Output + Send + Sync,

Transforms values without changing timing.

Source

fn zip<OtherValue, Other>(self, other: Other) -> Zip<Self, Other>
where Self: Sized, Other: Signal<OtherValue>,

Samples in parallel; the result is finite only if both inputs are finite.

Source

fn boxed(self) -> Arc<dyn Signal<Value>> ⓘ
where Self: Sized + 'static,

Shares a type-erased signal.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<Value> Signal<Value> for Arc<dyn FiniteAnimation<Value> + '_>

Source§

fn sample(&self, time: Time) -> Value

Source§

impl<Value> Signal<Value> for Arc<dyn Signal<Value> + '_>

Source§

fn sample(&self, time: Time) -> Value

Implementors§

Source§

impl Signal<PathSample> for FollowPath

Source§

impl Signal<f64> for Noise

Source§

impl Signal<f64> for Oscillator

Source§

impl<FirstValue, SecondValue, First, Second> Signal<(FirstValue, SecondValue)> for Zip<First, Second>
where First: Signal<FirstValue>, Second: Signal<SecondValue>,

Source§

impl<Input, Output, Source, Function> Signal<Output> for Map<Source, Function, Input>
where Source: Signal<Input>, Function: Fn(Input) -> Output + Send + Sync,

Source§

impl<Value, First: FiniteAnimation<Value>, Next: FiniteAnimation<Value>> Signal<Value> for Then<First, Next>

Source§

impl<Value, Function> Signal<Value> for Function
where Function: Fn(Time) -> Value + Send + Sync,

Source§

impl<Value, Source: FiniteAnimation<Value>> Signal<Value> for Delay<Source>

Source§

impl<Value, Source: FiniteAnimation<Value>> Signal<Value> for PingPong<Source>

Source§

impl<Value, Source: FiniteAnimation<Value>> Signal<Value> for Repeat<Source>

Source§

impl<Value, Source: FiniteAnimation<Value>> Signal<Value> for Reverse<Source>

Source§

impl<Value, Source: FiniteAnimation<Value>> Signal<Value> for Speed<Source>

Source§

impl<Value: Clone + Send + Sync> Signal<Value> for Constant<Value>

Source§

impl<Value: Interpolate + Send + Sync> Signal<Value> for Keyframes<Value>

Source§

impl<Value: Interpolate + Send + Sync> Signal<Value> for Spring<Value>

Source§

impl<Value: Interpolate + Send + Sync> Signal<Value> for Tween<Value>