[][src]Struct jnet::udp::Packet

pub struct Packet<BUFFER> where
    BUFFER: AsSlice<Element = u8>, 
{ /* fields omitted */ }

UDP packet

Methods

impl<B> Packet<B> where
    B: AsSlice<Element = u8>, 
[src]

pub fn parse(bytes: B) -> Result<Self, B>[src]

Parses the bytes as an UDP packet

pub fn get_source(&self) -> u16[src]

Returns the Source (port) field of the header

pub fn get_destination(&self) -> u16[src]

Returns the Destination (port) field of the header

pub fn get_length(&self) -> u16[src]

Returns the Length field of the header

pub fn len(&self) -> u16[src]

Returns the length (header + data) of this packet

pub fn payload(&self) -> &[u8][src]

View into the payload

pub fn as_bytes(&self) -> &[u8][src]

Returns the byte representation of this UDP packet

pub fn verify_ipv6_checksum(&self, src: Addr, dest: Addr) -> bool[src]

Verifies the 'Checksum' field

impl<B> Packet<B> where
    B: AsSlice<Element = u8> + AsMutSlice<Element = u8>, 
[src]

pub fn set_source(&mut self, port: u16)[src]

Sets the Source (port) field of the header

pub fn set_destination(&mut self, port: u16)[src]

Sets the Destination (port) field of the header

pub fn zero_checksum(&mut self)[src]

Zeroes the Checksum field of the header

pub fn payload_mut(&mut self) -> &mut [u8][src]

Mutable view into the payload

pub fn update_ipv6_checksum(&mut self, src: Addr, dest: Addr)[src]

Recomputes and updates the 'Checksum' field

impl<B> Packet<B> where
    B: AsSlice<Element = u8> + AsMutSlice<Element = u8> + Truncate<u16>, 
[src]

pub fn new(buffer: B) -> Self[src]

Transforms the given buffer into an UDP packet

NOTE The UDP packet will span the whole buffer and the Checksum field will be zeroed.

Panics

This constructor panics if the given buffer is not large enough to contain the UDP header.

pub fn set_payload(&mut self, data: &[u8])[src]

Fills the payload with the given data and adjusts the length of the UDP packet

pub fn coap<F>(&mut self, token_length: u8, f: F) where
    F: FnOnce(Message<&mut [u8], Unset>) -> Message<&mut [u8]>, 
[src]

Fills the payload with a CoAP message

pub fn truncate(&mut self, len: u16)[src]

Truncates the payload to the specified length

Trait Implementations

impl<B> Debug for Packet<B> where
    B: AsSlice<Element = u8>, 
[src]

NOTE excludes the payload

Auto Trait Implementations

impl<BUFFER> Unpin for Packet<BUFFER> where
    BUFFER: Unpin

impl<BUFFER> Send for Packet<BUFFER> where
    BUFFER: Send

impl<BUFFER> Sync for Packet<BUFFER> where
    BUFFER: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self