Struct flipdot_testing::VirtualSign [−][src]
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 Page
s 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]
&mut self,
message: &Message<'_>
) -> Option<Message<'a>>
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]
fn clone(&self) -> VirtualSign<'a>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> Debug for VirtualSign<'a>
[src]
impl<'a> Eq for VirtualSign<'a>
[src]
impl<'a> Hash for VirtualSign<'a>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a> PartialEq<VirtualSign<'a>> for VirtualSign<'a>
[src]
fn eq(&self, other: &VirtualSign<'a>) -> bool
[src]
fn ne(&self, other: &VirtualSign<'a>) -> bool
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,