[−][src]Struct jnet::udp::Packet
UDP packet
Methods
impl<B> Packet<B> where
B: AsSlice<Element = u8>,
[src]
B: AsSlice<Element = u8>,
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]
B: AsSlice<Element = u8> + AsMutSlice<Element = u8>,
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]
B: AsSlice<Element = u8> + AsMutSlice<Element = u8> + Truncate<u16>,
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]
F: FnOnce(Message<&mut [u8], Unset>) -> Message<&mut [u8]>,
Fills the payload with a CoAP message
pub fn truncate(&mut self, len: u16)
[src]
Truncates the payload to the specified length
Trait Implementations
Auto Trait Implementations
impl<BUFFER> Unpin for Packet<BUFFER> where
BUFFER: Unpin,
BUFFER: Unpin,
impl<BUFFER> Send for Packet<BUFFER> where
BUFFER: Send,
BUFFER: Send,
impl<BUFFER> Sync for Packet<BUFFER> where
BUFFER: Sync,
BUFFER: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self