kmc-solid: Implement AsFd
for {Arc,Rc,Box}<impl AsFd>
This commit is contained in:
parent
cf9c4a32f3
commit
0dd3b25e2d
@ -271,6 +271,39 @@ macro_rules! impl_owned_fd_traits {
|
|||||||
}
|
}
|
||||||
impl_owned_fd_traits! { TcpStream TcpListener UdpSocket }
|
impl_owned_fd_traits! { TcpStream TcpListener UdpSocket }
|
||||||
|
|
||||||
|
/// This impl allows implementing traits that require `AsFd` on Arc.
|
||||||
|
/// ```
|
||||||
|
/// # #[cfg(target_os = "solid_asp3")] mod group_cfg {
|
||||||
|
/// # use std::os::solid::io::AsFd;
|
||||||
|
/// use std::net::UdpSocket;
|
||||||
|
/// use std::sync::Arc;
|
||||||
|
///
|
||||||
|
/// trait MyTrait: AsFd {}
|
||||||
|
/// impl MyTrait for Arc<UdpSocket> {}
|
||||||
|
/// impl MyTrait for Box<UdpSocket> {}
|
||||||
|
/// # }
|
||||||
|
/// ```
|
||||||
|
impl<T: AsFd> AsFd for crate::sync::Arc<T> {
|
||||||
|
#[inline]
|
||||||
|
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||||
|
(**self).as_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: AsFd> AsFd for crate::rc::Rc<T> {
|
||||||
|
#[inline]
|
||||||
|
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||||
|
(**self).as_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: AsFd> AsFd for Box<T> {
|
||||||
|
#[inline]
|
||||||
|
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||||
|
(**self).as_fd()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A trait to extract the raw SOLID Sockets file descriptor from an underlying
|
/// A trait to extract the raw SOLID Sockets file descriptor from an underlying
|
||||||
/// object.
|
/// object.
|
||||||
pub trait AsRawFd {
|
pub trait AsRawFd {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user