pub struct UdpDatagram {
pub source: u16,
pub dest: u16,
pub checksum: u16,
pub payload: Vec<u8>,
}Expand description
UDP header and associated data
Fields§
§source: u16Source port
dest: u16Destination port
checksum: u16Packet checksum
payload: Vec<u8>UDP data
Implementations§
Source§impl UdpDatagram
impl UdpDatagram
Sourcepub fn parse_from_bytes(data: &dyn AsRef<[u8]>) -> Result<Self, UdpParseErr>
pub fn parse_from_bytes(data: &dyn AsRef<[u8]>) -> Result<Self, UdpParseErr>
Parse a udp packet from a slice of bytes
This method will not check the checksum.
§Errors
This method will return an error if the slice is less than 8 bytes or if the size of the length field is larger than the length of the slice.
Trait Implementations§
Source§impl Debug for UdpDatagram
impl Debug for UdpDatagram
Source§impl From<UdpDatagram> for DataType
impl From<UdpDatagram> for DataType
Source§fn from(packet: UdpDatagram) -> Self
fn from(packet: UdpDatagram) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for UdpDatagram
impl RefUnwindSafe for UdpDatagram
impl Send for UdpDatagram
impl Sync for UdpDatagram
impl Unpin for UdpDatagram
impl UnwindSafe for UdpDatagram
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