mirror of https://github.com/smol-rs/smol
Add AsRawFd/RawSocket on types with bound of them
This commit is contained in:
parent
53dee1c23e
commit
101dfe41d5
|
@ -9,7 +9,7 @@ use std::task::{Context, Poll};
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::{
|
use std::{
|
||||||
os::unix::io::AsRawFd,
|
os::unix::io::{AsRawFd, RawFd},
|
||||||
os::unix::net::{SocketAddr as UnixSocketAddr, UnixDatagram, UnixListener, UnixStream},
|
os::unix::net::{SocketAddr as UnixSocketAddr, UnixDatagram, UnixListener, UnixStream},
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
@ -54,6 +54,13 @@ impl<T: AsRawFd> Async<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
impl<T: AsRawFd> AsRawFd for Async<T> {
|
||||||
|
fn as_raw_fd(&self) -> RawFd {
|
||||||
|
self.source.raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
impl<T: AsRawSocket> Async<T> {
|
impl<T: AsRawSocket> Async<T> {
|
||||||
/// Converts a non-blocking I/O handle into an async I/O handle.
|
/// Converts a non-blocking I/O handle into an async I/O handle.
|
||||||
|
@ -67,6 +74,13 @@ impl<T: AsRawSocket> Async<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
impl<T: AsRawSocket> AsRawSocket for Async<T> {
|
||||||
|
fn as_raw_socket(&self) -> RawSocket {
|
||||||
|
self.source.raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Async<T> {
|
impl<T> Async<T> {
|
||||||
/// Gets a reference to the inner I/O handle.
|
/// Gets a reference to the inner I/O handle.
|
||||||
///
|
///
|
||||||
|
|
|
@ -245,11 +245,11 @@ impl ReactorLock<'_> {
|
||||||
pub(crate) struct Source {
|
pub(crate) struct Source {
|
||||||
/// Raw file descriptor on Unix platforms.
|
/// Raw file descriptor on Unix platforms.
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
raw: RawFd,
|
pub(crate) raw: RawFd,
|
||||||
|
|
||||||
/// Raw socket handle on Windows.
|
/// Raw socket handle on Windows.
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
raw: RawSocket,
|
pub(crate) raw: RawSocket,
|
||||||
|
|
||||||
/// The ID of this source obtain during registration.
|
/// The ID of this source obtain during registration.
|
||||||
key: usize,
|
key: usize,
|
||||||
|
|
Loading…
Reference in New Issue