pub struct UdpGroup { /* private fields */ }
Implementations§
Source§impl UdpGroup
impl UdpGroup
Sourcepub fn bind<S: ToSocketAddrs>(laddrs: S) -> Result<Self>
pub fn bind<S: ToSocketAddrs>(laddrs: S) -> Result<Self>
This function will create a new UDP socket and attempt to bind it to the addr provided.
Sourcepub async fn send_to<S: ToSocketAddrs>(
&self,
buf: &[u8],
target: S,
) -> Result<(SocketAddr, usize)>
pub async fn send_to<S: ToSocketAddrs>( &self, buf: &[u8], target: S, ) -> Result<(SocketAddr, usize)>
Sends data on the socket group to the given address. On success, returns the number of bytes written and send socket laddr.
pub async fn send_to_by<S: ToSocketAddrs>( &self, laddr: SocketAddr, buf: &[u8], target: S, ) -> Result<usize>
Sourcepub async fn recv_from<'a>(
&self,
buf: &'a mut [u8],
) -> Result<(SocketAddr, usize, SocketAddr)>
pub async fn recv_from<'a>( &self, buf: &'a mut [u8], ) -> Result<(SocketAddr, usize, SocketAddr)>
Receives data from the socket. On success, returns the number of bytes read and the address from whence the data came.
pub async fn recv_from_buf<B>(
&self,
buf: &mut B,
) -> Result<(SocketAddr, SocketAddr)>where
B: BufMut,
pub fn local_addrs(&self) -> impl Iterator<Item = &SocketAddr>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UdpGroup
impl RefUnwindSafe for UdpGroup
impl Send for UdpGroup
impl Sync for UdpGroup
impl Unpin for UdpGroup
impl UnwindSafe for UdpGroup
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more