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