pub struct Header {
pub id: u8,
pub size: u16,
pub order: u8,
}Expand description
The header on every message, either way.
Fields§
§id: u8An identifier the host picks. The bridge does not check it and the reference does not compare it on the way back, so it is a courtesy rather than a guard.
size: u16How many bytes of payload follow.
order: u8What the message is, or, from the bridge, what it answers.
Implementations§
Source§impl Header
impl Header
Sourcepub const fn from_bytes(bytes: [u8; 4]) -> Header
pub const fn from_bytes(bytes: [u8; 4]) -> Header
Sourcepub const fn is_answer(&self) -> bool
pub const fn is_answer(&self) -> bool
Whether this header answers an order, rather than carrying one.
§Returns
Whether the order is in the range the bridge answers with.
Sourcepub const fn answers(&self, order: u8) -> bool
pub const fn answers(&self, order: u8) -> bool
Whether this header answers a particular order.
§Arguments
order- the order that was sent.
§Returns
Whether the bridge answered that one.
§Examples
use pamoja_radios::sx1302::bridge::{Header, ACK, ORDER_PING};
let answer = Header::from_bytes([7, 0, 21, ORDER_PING + ACK]);
assert!(answer.answers(ORDER_PING));
assert!(!answer.answers(ORDER_PING + 1));Trait Implementations§
impl Copy for Header
impl Eq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnsafeUnpin for Header
impl UnwindSafe for Header
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