UdpDatagram

Struct UdpDatagram 

Source
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: u16

Source port

§dest: u16

Destination port

§checksum: u16

Packet checksum

§payload: Vec<u8>

UDP data

Implementations§

Source§

impl UdpDatagram

Source

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.

Source

pub fn pcap_write<W: Write>(&self, f: &mut W) -> Result<()>

Write packet to a pcap file

§Errors

Will return any io errors that occur.

Trait Implementations§

Source§

impl Debug for UdpDatagram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<UdpDatagram> for DataType

Source§

fn from(packet: UdpDatagram) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.