Struct Header
pub(crate) struct Header {
pub(crate) kind: Kind,
pub(crate) txn_id: u16,
pub(crate) msg_id: u16,
pub(crate) len: u16,
}Expand description
Message header.
Fields§
§kind: Kind§txn_id: u16§msg_id: u16§len: u16Implementations§
§impl Header
impl Header
pub(crate) fn encode(self) -> [u8; 7]
pub(crate) fn decode(packet: &[u8]) -> Option<(Self, &[u8])>
pub(crate) fn decode(packet: &[u8]) -> Option<(Self, &[u8])>
Parses the header and returns it with the payload.
The payload length can differ from Header::len, see
Header::check_len.
pub(crate) fn check_len(self, payload: &[u8]) -> Result<(), DecodeError>
pub(crate) fn check_len(self, payload: &[u8]) -> Result<(), DecodeError>
Checks that the payload has the length given in the header.
§Errors
Returns DecodeError::Truncated if the payload is shorter, or
DecodeError::TrailingData if it is longer.
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