[][src]Struct aimc_hal::automation::All

pub struct All<A, const N: usize> { /* fields omitted */ }

A combinator which combines many AutomationSequences and will poll them all to completion, stopping when either a fault is raised or there are no more incomplete sequences.

Examples

use aimc_hal::automation::{AutomationSequence, Transition, All};

/// A simple automation sequence which will return `Transition::Incomplete`
/// until it reaches zero.
struct CountDown(usize);

impl<I, O> AutomationSequence<I, O> for CountDown {
    type FaultInfo = ();

    fn poll(&mut self, inputs: &I, outputs: &mut O) -> Transition<()> {
        if self.0 == 0 {
            Transition::Complete
        } else {
            self.0 -= 1;
            Transition::Incomplete
        }
    }
}

// Combine the sequences into one big automation sequence
let mut seq = All::new([CountDown(1), CountDown(5), CountDown(2)]);

// we'll keep track of the number of polls
let mut polls = 0;

// keep polling until all the timers have reached zero
while seq.poll(&(), &mut ()) != Transition::Complete {
    polls += 1;
}

// we should have polled 5 times (`max(1, 5, 2)`)
assert_eq!(polls, 5);

Implementations

impl<A, const N: usize> All<A, { N }>[src]

pub fn new(items: [A; N]) -> Self[src]

Trait Implementations

impl<I, O, A, const N: usize> AutomationSequence<I, O> for All<A, { N }> where
    A: AutomationSequence<I, O>, 
[src]

type FaultInfo = A::FaultInfo

Extra info attached to a fault.

impl<A, const N: usize> Clone for All<A, { N }> where
    [Option<A>; N]: LengthAtMost32,
    [Option<A>; N]: Clone
[src]

impl<A, const N: usize> Copy for All<A, { N }> where
    [Option<A>; N]: LengthAtMost32,
    [Option<A>; N]: Copy
[src]

impl<A, const N: usize> Debug for All<A, { N }> where
    [Option<A>; N]: LengthAtMost32,
    [Option<A>; N]: Debug
[src]

impl<A, const N: usize> Default for All<A, { N }> where
    [Option<A>; N]: LengthAtMost32,
    [Option<A>; N]: Default
[src]

impl<A, const N: usize> PartialEq<All<A, N>> for All<A, { N }> where
    [Option<A>; N]: LengthAtMost32,
    [Option<A>; N]: PartialEq
[src]

Auto Trait Implementations

impl<const N: usize, A> RefUnwindSafe for All<A, N> where
    A: RefUnwindSafe

impl<const N: usize, A> Send for All<A, N> where
    A: Send

impl<const N: usize, A> Sync for All<A, N> where
    A: Sync

impl<const N: usize, A> Unpin for All<A, N> where
    A: Unpin

impl<const N: usize, A> UnwindSafe for All<A, N> where
    A: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.