pub struct SweeperMessage {
pub cmd: u8,
pub data: Vec<u8>,
pub checksum_ok: bool,
}Expand description
A decoded DP 15 message from the vacuum cleaner.
Fields§
§cmd: u8Command byte.
data: Vec<u8>Payload data (without header and checksum).
checksum_ok: boolWhether the checksum validated correctly.
Implementations§
Source§impl SweeperMessage
impl SweeperMessage
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, ProtocolError>
pub fn decode(bytes: &[u8]) -> Result<Self, ProtocolError>
Decode from raw bytes.
§Examples
use xplorer_rs::protocol::SweeperMessage;
let bytes = [0xAA, 0x00, 0x04, 0x15, 0x01, 0x01, 0x04, 0x1B];
let msg = SweeperMessage::decode(&bytes).unwrap();
assert_eq!(msg.cmd, 0x15);
assert!(msg.checksum_ok);Sourcepub fn decode_base64(s: &str) -> Result<Self, ProtocolError>
pub fn decode_base64(s: &str) -> Result<Self, ProtocolError>
Decode from base64 string.
§Examples
use xplorer_rs::protocol::SweeperMessage;
let msg = SweeperMessage::decode_base64("qgAEFQEBBBs=").unwrap();
assert_eq!(msg.cmd, 0x15);
assert_eq!(msg.data, vec![0x01, 0x01, 0x04]);Trait Implementations§
Source§impl Clone for SweeperMessage
impl Clone for SweeperMessage
Source§fn clone(&self) -> SweeperMessage
fn clone(&self) -> SweeperMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SweeperMessage
impl Debug for SweeperMessage
Source§impl PartialEq for SweeperMessage
impl PartialEq for SweeperMessage
Source§impl TryFrom<&SweeperMessage> for RoomCleanStatusResponse
impl TryFrom<&SweeperMessage> for RoomCleanStatusResponse
Source§type Error = ProtocolError
type Error = ProtocolError
The type returned in the event of a conversion error.
impl Eq for SweeperMessage
impl StructuralPartialEq for SweeperMessage
Auto Trait Implementations§
impl Freeze for SweeperMessage
impl RefUnwindSafe for SweeperMessage
impl Send for SweeperMessage
impl Sync for SweeperMessage
impl Unpin for SweeperMessage
impl UnsafeUnpin for SweeperMessage
impl UnwindSafe for SweeperMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.