pub struct SixlowpanUdpNhcRepr {
pub src_port: u16,
pub dst_port: u16,
pub checksum: Option<u16>,
}Expand description
The fields of a 6LoWPAN NHC UDP header.
The header starts with the following byte (RFC 6282 § 4.3):
0 1 2 3 4 5 6 7
+---+---+---+---+---+---+---+---+
| 1 | 1 | 1 | 1 | 0 | C | P |
+---+---+---+---+---+---+---+---+C says whether the checksum is elided, P how much of the ports is. The inline port bits and the checksum follow it.
Fields§
§src_port: u16§dst_port: u16§checksum: Option<u16>The checksum. None when it is elided: the receiver must recompute it
over the whole datagram.
Implementations§
Source§impl UdpNhcRepr
impl UdpNhcRepr
Sourcepub fn parse(buf: &[u8]) -> Result<(Self, usize)>
pub fn parse(buf: &[u8]) -> Result<(Self, usize)>
Parse a compressed UDP header from the front of buf.
Returns the header and its length, not counting the payload.
Errors:
Errorif the buffer is shorter than the header, or does not start with a UDP header dispatch.
Sourcepub fn buffer_len(&self) -> usize
pub fn buffer_len(&self) -> usize
Return the length of the header this will emit, not counting the payload.
Sourcepub fn emit(&self, buf: &mut [u8])
pub fn emit(&self, buf: &mut [u8])
Write the header into the front of buf.
Writes exactly buffer_len bytes.
§Panics
Panics if buf is shorter than buffer_len.
Trait Implementations§
Source§impl Clone for UdpNhcRepr
impl Clone for UdpNhcRepr
Source§fn clone(&self) -> UdpNhcRepr
fn clone(&self) -> UdpNhcRepr
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for UdpNhcRepr
Source§impl Debug for UdpNhcRepr
impl Debug for UdpNhcRepr
impl Eq for UdpNhcRepr
Source§impl PartialEq for UdpNhcRepr
impl PartialEq for UdpNhcRepr
impl StructuralPartialEq for UdpNhcRepr
Auto Trait Implementations§
impl Freeze for UdpNhcRepr
impl RefUnwindSafe for UdpNhcRepr
impl Send for UdpNhcRepr
impl Sync for UdpNhcRepr
impl Unpin for UdpNhcRepr
impl UnsafeUnpin for UdpNhcRepr
impl UnwindSafe for UdpNhcRepr
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