Skip to main content

UdpOptions

Struct UdpOptions 

Source
pub struct UdpOptions { /* private fields */ }
Available on crate feature udp only.
Expand description

Options for UdpSocket::bind_with.

use net_io::{UdpBudget, UdpOptions};
let options = UdpOptions::new()
    .amplification_factor(3) // a QUIC handshake (RFC 9000)
    .global_budget(UdpBudget { datagrams_per_sec: 50_000, bytes_per_sec: 60_000_000, burst: 5_000 });

Implementations§

Source§

impl UdpOptions

Source

pub fn new() -> UdpOptions

Factor 1, a 10 s window, UdpBudget::SOURCE_DEFAULT per source, no global budget, 65,536 sources, IPv6-only for IPv6 addresses.

Source

pub fn amplification_factor(self, factor: u8) -> UdpOptions

How many times the bytes received from an unverified source may be sent back to it (1 by default, at most 3; decision D-034).

Source

pub fn amplification_window(self, window: Duration) -> UdpOptions

How long received bytes count toward a source’s send allowance (10 s by default, at least 1 s). The allowance spans the current and the previous window, so a reply just after a window boundary is not refused.

Source

pub fn source_budget(self, budget: UdpBudget) -> UdpOptions

The budget of each source address.

Source

pub fn global_budget(self, budget: UdpBudget) -> UdpOptions

A budget for the whole socket (none by default).

Source

pub fn source_table(self, entries: u32) -> UdpOptions

How many sources are tracked (65,536 by default, about 130 bytes each).

Source

pub fn packet_info(self, on: bool) -> UdpOptions

IPV6_V6ONLY for an IPv6 address (on by default). Off, an IPv6 socket also receives IPv4; sources are reported as IPv4 and replies to them work. Reports each datagram’s destination address in Datagram::destination, for a socket bound to a wildcard that must answer from the address it was asked on. One recvmsg per datagram instead of recvfrom. Unix only: bind_with fails with Unsupported on Windows, and recv_batch does not fill it.

Source

pub fn ipv6_only(self, on: bool) -> UdpOptions

IPV6_V6ONLY for IPv6 addresses (on by default).

Trait Implementations§

Source§

impl Clone for UdpOptions

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 Debug for UdpOptions

Source§

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

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

impl Default for UdpOptions

Source§

fn default() -> UdpOptions

Returns the “default value” for a type. Read more
Source§

impl Eq for UdpOptions

Source§

impl PartialEq for UdpOptions

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 StructuralPartialEq for UdpOptions

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.