pub struct UdpSocket { /* private fields */ }Implementations§
Source§impl UdpSocket
impl UdpSocket
pub async fn with<F, R>(&self, f: F) -> Rwhere
F: FnOnce(&Socket<'static>) -> R,
pub async fn with_mutable<F, R>(&self, f: F) -> Rwhere
F: FnOnce(&mut Socket<'static>) -> R,
pub fn poll_with<F, R>(&self, context: &mut Context<'_>, f: F) -> Poll<R>
pub fn poll_with_mutable<F, R>( &self, context: &mut Context<'_>, f: F, ) -> Poll<R>
Sourcepub async fn bind_ephemeral(&mut self) -> Result<Port>
pub async fn bind_ephemeral(&mut self) -> Result<Port>
Bind to the next ephemeral port the stack allocates, for a client that sends first. Returns the bound port.
Sourcepub async fn rebind_ephemeral(&mut self) -> Result<Port>
pub async fn rebind_ephemeral(&mut self) -> Result<Port>
Close the current binding and bind a fresh ephemeral port, dropping any queued datagrams: each exchange then sends from a new source port.
pub async fn bind(&mut self, port: Port) -> Result<()>
pub fn poll_send_to( &mut self, context: &mut Context<'_>, buffer: &[u8], metadata: &UdpMetadata, ) -> Poll<Result<()>>
pub fn poll_receive_from( &self, context: &mut Context<'_>, buffer: &mut [u8], ) -> Poll<Result<(usize, UdpMetadata)>>
pub async fn write_to( &mut self, buffer: &[u8], metadata: &UdpMetadata, ) -> Result<()>
pub async fn read_from(&self, buffer: &mut [u8]) -> Result<(usize, UdpMetadata)>
pub fn flush(&mut self) -> impl Future<Output = ()> + '_
Sourcepub async fn close(&mut self)
pub async fn close(&mut self)
Close the socket in place. The owner drops it afterwards, so one that holds it in a registry can close it while it is still registered, and close it again if a cancellation interrupts this call.
pub async fn get_endpoint(&self) -> Result<(Option<IpAddress>, Port)>
pub async fn get_packet_read_capacity(&self) -> usize
pub async fn get_packet_write_capacity(&self) -> usize
pub async fn get_payload_read_capacity(&self) -> usize
pub async fn get_payload_write_capacity(&self) -> usize
pub async fn set_hop_limit(&mut self, hop_limit: Option<u8>)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UdpSocket
impl !RefUnwindSafe for UdpSocket
impl Send for UdpSocket
impl Sync for UdpSocket
impl Unpin for UdpSocket
impl UnsafeUnpin for UdpSocket
impl !UnwindSafe for UdpSocket
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