Skip to main content

UdpDatagram

Struct UdpDatagram 

Source
pub struct UdpDatagram<'a> { /* private fields */ }
Expand description

A structurally validated UDP datagram.

Implementations§

Source§

impl<'a> UdpDatagram<'a>

Source

pub fn kcp_segments(&self) -> Result<KcpSegments<'a>, KcpSegmentsParseError>

Validates the complete UDP payload as a nonempty KCP segment sequence.

Source§

impl UdpDatagram<'_>

Source

pub fn checksum_status_ipv4( &self, source: Ipv4Address, destination: Ipv4Address, ) -> UdpChecksumStatus

Returns the validation state of this datagram’s IPv4 checksum.

Source§

impl UdpDatagram<'_>

Source

pub fn checksum_is_valid_ipv6( &self, source: Ipv6Address, destination: Ipv6Address, ) -> bool

Checks this datagram against its required IPv6 pseudoheader checksum.

Source§

impl<'a> UdpDatagram<'a>

Source

pub fn parse(bytes: &'a [u8]) -> Result<Self, ParseError>

Parses a UDP datagram without checking its checksum.

Source

pub fn source_port(&self) -> u16

Returns the source port.

Source

pub fn destination_port(&self) -> u16

Returns the destination port.

Source

pub fn length(&self) -> u16

Returns the encoded datagram length.

Source

pub fn checksum(&self) -> u16

Returns the encoded checksum.

Source

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

Returns payload bytes.

Source

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

Returns all represented datagram bytes.

Trait Implementations§

Source§

impl<'a> Clone for UdpDatagram<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for UdpDatagram<'a>

Source§

impl<'a> Debug for UdpDatagram<'a>

Source§

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

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

impl<'a> Eq for UdpDatagram<'a>

Source§

impl<'a> PartialEq for UdpDatagram<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for UdpDatagram<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for UdpDatagram<'a>

§

impl<'a> RefUnwindSafe for UdpDatagram<'a>

§

impl<'a> Send for UdpDatagram<'a>

§

impl<'a> Sync for UdpDatagram<'a>

§

impl<'a> Unpin for UdpDatagram<'a>

§

impl<'a> UnsafeUnpin for UdpDatagram<'a>

§

impl<'a> UnwindSafe for UdpDatagram<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.