pub struct UdpSocket { /* private fields */ }Expand description
A UDP socket.
Implementations§
Source§impl UdpSocket
impl UdpSocket
Sourcepub fn bind(addr: SocketAddr) -> Result<Self>
pub fn bind(addr: SocketAddr) -> Result<Self>
Binds on a given address.
Sourcepub async fn send_to<S: State, const TASKS: usize, const TASK_SIZE: usize, const ROOT_TASK_SIZE: usize, const TIMERS: usize, const FDS: usize>(
&mut self,
ctx: &Context<'_, S, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>,
buf: &[u8],
addr: SocketAddr,
) -> Result<usize>
pub async fn send_to<S: State, const TASKS: usize, const TASK_SIZE: usize, const ROOT_TASK_SIZE: usize, const TIMERS: usize, const FDS: usize>( &mut self, ctx: &Context<'_, S, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>, buf: &[u8], addr: SocketAddr, ) -> Result<usize>
Sends a given buffer to a given address.
Sourcepub fn recv_from<'a, 'ctx, S: State, const TASKS: usize, const TASK_SIZE: usize, const ROOT_TASK_SIZE: usize, const TIMERS: usize, const FDS: usize>(
&'a mut self,
ctx: &'a Context<'ctx, S, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>,
buf: &'a mut [u8],
) -> impl Future<Output = Result<(usize, SocketAddr)>>
pub fn recv_from<'a, 'ctx, S: State, const TASKS: usize, const TASK_SIZE: usize, const ROOT_TASK_SIZE: usize, const TIMERS: usize, const FDS: usize>( &'a mut self, ctx: &'a Context<'ctx, S, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>, buf: &'a mut [u8], ) -> impl Future<Output = Result<(usize, SocketAddr)>>
Receives a datagram from any sender into a given buffer, returns its size and the sender address.
Sourcepub fn connect(&self, addr: SocketAddr) -> Result<()>
pub fn connect(&self, addr: SocketAddr) -> Result<()>
Sourcepub fn send<'a, 'ctx, S: State, const TASKS: usize, const TASK_SIZE: usize, const ROOT_TASK_SIZE: usize, const TIMERS: usize, const FDS: usize>(
&'a mut self,
ctx: &'a Context<'ctx, S, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>,
buf: &'a [u8],
) -> impl Future<Output = Result<usize>>
pub fn send<'a, 'ctx, S: State, const TASKS: usize, const TASK_SIZE: usize, const ROOT_TASK_SIZE: usize, const TIMERS: usize, const FDS: usize>( &'a mut self, ctx: &'a Context<'ctx, S, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>, buf: &'a [u8], ) -> impl Future<Output = Result<usize>>
Sends a given buffer to the connected peer, see connect.
Sourcepub fn recv<'a, 'ctx, S: State, const TASKS: usize, const TASK_SIZE: usize, const ROOT_TASK_SIZE: usize, const TIMERS: usize, const FDS: usize>(
&'a mut self,
ctx: &'a Context<'ctx, S, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>,
buf: &'a mut [u8],
) -> impl Future<Output = Result<usize>>
pub fn recv<'a, 'ctx, S: State, const TASKS: usize, const TASK_SIZE: usize, const ROOT_TASK_SIZE: usize, const TIMERS: usize, const FDS: usize>( &'a mut self, ctx: &'a Context<'ctx, S, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>, buf: &'a mut [u8], ) -> impl Future<Output = Result<usize>>
Receives a datagram from the connected peer into a given buffer, see connect.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns local address.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for UdpSocket
impl !RefUnwindSafe for UdpSocket
impl !Sync for UdpSocket
impl Forget for UdpSocket
impl Send 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