pub struct UdpConfig {
pub socket_family: SocketFamily,
pub socket_type: UdpSocketType,
pub bind_addr: Option<SocketAddr>,
pub reuseaddr: Option<bool>,
pub broadcast: Option<bool>,
pub ttl: Option<u32>,
pub hoplimit: Option<u32>,
pub read_timeout: Option<Duration>,
pub write_timeout: Option<Duration>,
pub bind_device: Option<String>,
}Expand description
Configuration options for a UDP socket.
Fields§
§socket_family: SocketFamilyThe socket family.
socket_type: UdpSocketTypeThe socket type (DGRAM or RAW).
bind_addr: Option<SocketAddr>Address to bind. If None, the operating system chooses the address.
reuseaddr: Option<bool>Enable address reuse (SO_REUSEADDR).
broadcast: Option<bool>Allow broadcast (SO_BROADCAST).
ttl: Option<u32>Time to live value.
hoplimit: Option<u32>Hop limit value.
read_timeout: Option<Duration>Read timeout for the socket.
write_timeout: Option<Duration>Write timeout for the socket.
bind_device: Option<String>Bind to a specific interface (Linux only).
Implementations§
Source§impl UdpConfig
impl UdpConfig
Sourcepub fn with_bind_addr(self, addr: SocketAddr) -> Self
pub fn with_bind_addr(self, addr: SocketAddr) -> Self
Set the bind address.
Sourcepub fn with_reuseaddr(self, on: bool) -> Self
pub fn with_reuseaddr(self, on: bool) -> Self
Enable address reuse.
Sourcepub fn with_broadcast(self, on: bool) -> Self
pub fn with_broadcast(self, on: bool) -> Self
Allow broadcast.
Sourcepub fn with_hoplimit(self, hops: u32) -> Self
pub fn with_hoplimit(self, hops: u32) -> Self
Set the hop limit value.
Sourcepub fn with_read_timeout(self, timeout: Duration) -> Self
pub fn with_read_timeout(self, timeout: Duration) -> Self
Set the read timeout.
Sourcepub fn with_write_timeout(self, timeout: Duration) -> Self
pub fn with_write_timeout(self, timeout: Duration) -> Self
Set the write timeout.
Sourcepub fn with_bind_device(self, iface: impl Into<String>) -> Self
pub fn with_bind_device(self, iface: impl Into<String>) -> Self
Bind to a specific interface (Linux only).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UdpConfig
impl RefUnwindSafe for UdpConfig
impl Send for UdpConfig
impl Sync for UdpConfig
impl Unpin for UdpConfig
impl UnwindSafe for UdpConfig
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