|
|
@ -45,6 +45,8 @@ pub struct UnixDatagram {
|
|
|
|
|
|
|
|
|
|
|
|
impl UnixDatagram {
|
|
|
|
impl UnixDatagram {
|
|
|
|
fn new(socket: StdUnixDatagram) -> UnixDatagram {
|
|
|
|
fn new(socket: StdUnixDatagram) -> UnixDatagram {
|
|
|
|
|
|
|
|
once_cell::sync::Lazy::force(&crate::rt::RUNTIME);
|
|
|
|
|
|
|
|
|
|
|
|
UnixDatagram {
|
|
|
|
UnixDatagram {
|
|
|
|
watcher: Async::new(socket).expect("UnixDatagram is known to be good"),
|
|
|
|
watcher: Async::new(socket).expect("UnixDatagram is known to be good"),
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -64,6 +66,8 @@ impl UnixDatagram {
|
|
|
|
/// # Ok(()) }) }
|
|
|
|
/// # Ok(()) }) }
|
|
|
|
/// ```
|
|
|
|
/// ```
|
|
|
|
pub async fn bind<P: AsRef<Path>>(path: P) -> io::Result<UnixDatagram> {
|
|
|
|
pub async fn bind<P: AsRef<Path>>(path: P) -> io::Result<UnixDatagram> {
|
|
|
|
|
|
|
|
once_cell::sync::Lazy::force(&crate::rt::RUNTIME);
|
|
|
|
|
|
|
|
|
|
|
|
let path = path.as_ref().to_owned();
|
|
|
|
let path = path.as_ref().to_owned();
|
|
|
|
let socket = Async::<StdUnixDatagram>::bind(path)?;
|
|
|
|
let socket = Async::<StdUnixDatagram>::bind(path)?;
|
|
|
|
Ok(UnixDatagram { watcher: socket })
|
|
|
|
Ok(UnixDatagram { watcher: socket })
|
|
|
@ -305,6 +309,8 @@ impl fmt::Debug for UnixDatagram {
|
|
|
|
impl From<StdUnixDatagram> for UnixDatagram {
|
|
|
|
impl From<StdUnixDatagram> for UnixDatagram {
|
|
|
|
/// Converts a `std::os::unix::net::UnixDatagram` into its asynchronous equivalent.
|
|
|
|
/// Converts a `std::os::unix::net::UnixDatagram` into its asynchronous equivalent.
|
|
|
|
fn from(datagram: StdUnixDatagram) -> UnixDatagram {
|
|
|
|
fn from(datagram: StdUnixDatagram) -> UnixDatagram {
|
|
|
|
|
|
|
|
once_cell::sync::Lazy::force(&crate::rt::RUNTIME);
|
|
|
|
|
|
|
|
|
|
|
|
UnixDatagram {
|
|
|
|
UnixDatagram {
|
|
|
|
watcher: Async::new(datagram).expect("UnixDatagram is known to be good"),
|
|
|
|
watcher: Async::new(datagram).expect("UnixDatagram is known to be good"),
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -319,6 +325,8 @@ impl AsRawFd for UnixDatagram {
|
|
|
|
|
|
|
|
|
|
|
|
impl FromRawFd for UnixDatagram {
|
|
|
|
impl FromRawFd for UnixDatagram {
|
|
|
|
unsafe fn from_raw_fd(fd: RawFd) -> UnixDatagram {
|
|
|
|
unsafe fn from_raw_fd(fd: RawFd) -> UnixDatagram {
|
|
|
|
|
|
|
|
once_cell::sync::Lazy::force(&crate::rt::RUNTIME);
|
|
|
|
|
|
|
|
|
|
|
|
let raw = StdUnixDatagram::from_raw_fd(fd);
|
|
|
|
let raw = StdUnixDatagram::from_raw_fd(fd);
|
|
|
|
let datagram = Async::<StdUnixDatagram>::new(raw).expect("invalid file descriptor");
|
|
|
|
let datagram = Async::<StdUnixDatagram>::new(raw).expect("invalid file descriptor");
|
|
|
|
UnixDatagram { watcher: datagram }
|
|
|
|
UnixDatagram { watcher: datagram }
|
|
|
|