Enum flipdot_core::Message [−][src]
High-level representation of a sign bus communication message.
Ascribes meaning to a Frame
and is freely convertible to and from one
(with Unknown
to allow round-tripping unknown message types). This is the
primary way that messages are represented in flipdot
.
Examples
use flipdot_core::{Address, Message, SignBus, State}; use flipdot_testing::{VirtualSign, VirtualSignBus}; let mut bus = VirtualSignBus::new(vec![VirtualSign::new(Address(3))]); // Message is the currency used to send and receive messages on a bus: let response = bus.process_message(Message::QueryState(Address(3)))?; assert_eq!(Some(Message::ReportState(Address(3), State::Unconfigured)), response);
Variants (Non-exhaustive)
Send a chunk of data, with the first member indicating the offset.
E.g. when sending 32 bytes of data in two 16-byte chunks, the first message would have offset 0 and the second would have offset 16. No response is expected.
DataChunksSent(ChunkCount)
Notifies that we are done sending data, and specifies how many chunks were sent.
No response is expected.
Hello(Address)
Initially discovers the sign with the given address on the bus.
A ReportState
message with the sign’s current state is expected.
QueryState(Address)
Queries the sign with the given address for its current state.
A ReportState
message with the sign’s current state is expected.
Indicates the state of the sign with the given address.
Sent by the sign in response to a Hello
orQueryState
message.
Requests that the sign with the given address perform an operation.
An AckOperation
response is expected.
Sent by the sign with the given address indicating that it will perform the given operation.
PixelsComplete(Address)
Indicates that the pixel data for the sign with the given address has been fully transferred.
This indicates that the sign should load it into memory in preparation to show. No response is expected.
Goodbye(Address)
Notifies the sign with the given address to blank its display and shut down.
The sign will not be usable for 30 seconds after receiving this message. Generally optional as disconnecting switched power from the sign should have the same effect. No response is expected.
Unknown(Frame<'a>)
Wraps a Frame
that does not correspond to any known message.
Trait Implementations
impl<'a> Clone for Message<'a>
[src]
impl<'a> Debug for Message<'a>
[src]
impl Display for Message<'_>
[src]
fn fmt(&self, f: &mut Formatter<'_>) -> Result
[src]
Provides a human-readable view of the message.
This is useful, for example, when monitoring the traffic on a bus.
impl<'a> Eq for Message<'a>
[src]
impl<'a> From<Frame<'a>> for Message<'a>
[src]
fn from(frame: Frame<'a>) -> Self
[src]
Converts a Frame
into a Message
.
This cannot fail as all valid Frame
s are representable as Message
s (though perhaps Unknown
).
The input Frame
is consumed to allow efficiently reusing its data where possible.
Examples
let frame = Frame::new(Address(0x12), MsgType(4), Data::try_new(vec![0x07])?); let message = Message::from(frame); assert_eq!(Message::ReportState(Address(0x12), State::ConfigReceived), message);
impl<'a> From<Message<'a>> for Frame<'a>
[src]
fn from(message: Message<'a>) -> Self
[src]
Converts a Message
into a Frame
.
This cannot fail as all Message
s can be represented as Frame
s.
The input Message
is consumed to allow efficiently reusing its data where possible.
Examples
let message = Message::ReportState(Address(0xFF), State::ConfigReceived); let frame = Frame::from(message); assert_eq!(Frame::new(Address(0xFF), MsgType(4), Data::try_new(vec![0x07])?), frame);
impl<'a> Hash for Message<'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<Message<'a>> for Message<'a>
[src]
impl<'a> StructuralEq for Message<'a>
[src]
impl<'a> StructuralPartialEq for Message<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Message<'a>
impl<'a> Send for Message<'a>
impl<'a> Sync for Message<'a>
impl<'a> Unpin for Message<'a>
impl<'a> UnwindSafe for Message<'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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,