Struct flipdot_testing::VirtualSign[][src]

pub struct VirtualSign<'a> { /* fields omitted */ }

Mock implementation of a single sign on a VirtualSignBus.

Encapsulates all the state associated with a virtual sign and implements the sign protocol for it. In general, you do not need to interact with this class directly; you simply pass it off to a VirtualSignBus, which forwards messages appropriately.

Examples

See VirtualSignBus.

Implementations

impl VirtualSign<'_>[src]

pub fn new(address: Address) -> Self[src]

Creates a new VirtualSign with the specified address.

Examples

let sign = VirtualSign::new(Address(22));
let bus = VirtualSignBus::new(iter::once(sign));

pub fn address(&self) -> Address[src]

Returns the sign’s address.

Examples

let sign = VirtualSign::new(Address(22));
assert_eq!(Address(22), sign.address());

pub fn state(&self) -> State[src]

Returns the sign’s current state.

Examples

let sign = VirtualSign::new(Address(3));
assert_eq!(State::Unconfigured, sign.state());

pub fn sign_type(&self) -> Option<SignType>[src]

Returns the sign’s configured type.

This is initially None and will only be set if the sign has received a configuration message over the bus. Note that even if it has, this may still be None if the configuration did not match any known types (e.g. potentially when driving from a real ODK).

Examples

let sign = VirtualSign::new(Address(17));
assert_eq!(None, sign.sign_type());

pub fn pages(&self) -> &[Page<'_>][src]

Returns the sign’s current Pages as a slice.

May be empty if no pages have yet been sent to this sign or it has been reset.

Examples

let sign = VirtualSign::new(Address(1));
assert!(sign.pages().is_empty());

pub fn process_message<'a>(
    &mut self,
    message: &Message<'_>
) -> Option<Message<'a>>
[src]

Handle a bus message, updating our state accordingly.

Examples

let mut sign = VirtualSign::new(Address(3));
let response = sign.process_message(&Message::QueryState(Address(3)));
assert_eq!(Some(Message::ReportState(Address(3), State::Unconfigured)), response);

Trait Implementations

impl<'a> Clone for VirtualSign<'a>[src]

impl<'a> Debug for VirtualSign<'a>[src]

impl<'a> Eq for VirtualSign<'a>[src]

impl<'a> Hash for VirtualSign<'a>[src]

impl<'a> PartialEq<VirtualSign<'a>> for VirtualSign<'a>[src]

impl<'a> StructuralEq for VirtualSign<'a>[src]

impl<'a> StructuralPartialEq for VirtualSign<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for VirtualSign<'a>

impl<'a> Send for VirtualSign<'a>

impl<'a> Sync for VirtualSign<'a>

impl<'a> Unpin for VirtualSign<'a>

impl<'a> UnwindSafe for VirtualSign<'a>

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