/// `port_associate(_, PORT_SOURCE_FD, _, _, _)`—Associates a file descriptor /// with a port. /// /// # Safety /// /// Any `object`s passed into the `port` must be valid for the lifetime of the /// `port`. Logically, `port` keeps a borrowed reference to the `object` until /// it is removed via [`dissociate_fd`]. /// /// # References /// - [OpenSolaris] /// - [illumos] /// /// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_associate/ /// [illumos]: https://illumos.org/man/3C/port_associate #[doc(alias = "port_associate")] pubunsafefn associate_fd<Fd: AsFd, RawFd: AsRawFd>(
port: Fd,
object: RawFd,
events: PollFlags,
userdata: *mut ffi::c_void,
) -> io::Result<()> {
syscalls::port_associate(
port.as_fd(),
c::PORT_SOURCE_FD,
object.as_raw_fd() as _,
events.bits() as _,
userdata.cast(),
)
}
/// `port_dissociate(_, PORT_SOURCE_FD, _)`—Dissociates a file descriptor /// from a port. /// /// # Safety /// /// The file descriptor passed into this function must have been previously /// associated with the port via [`associate_fd`]. /// /// # References /// - [OpenSolaris] /// - [illumos] /// /// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_dissociate /// [illumos]: https://illumos.org/man/3C/port_dissociate #[doc(alias = "port_dissociate")] pubunsafefn dissociate_fd<Fd: AsFd, RawFd: AsRawFd>(port: Fd, object: RawFd) -> io::Result<()> {
syscalls::port_dissociate(port.as_fd(), c::PORT_SOURCE_FD, object.as_raw_fd() as _)
}
/// `port_get(port, timeout)`—Gets an event from a port. /// /// If an unsupported timeout is passed, this function fails with /// [`io::Errno::INVAL`]. /// /// # References /// - [OpenSolaris] /// - [illumos] /// /// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_get/ /// [illumos]: https://illumos.org/man/3C/port_get #[doc(alias = "port_get")] pubfn get<Fd: AsFd>(port: Fd, timeout: Option<&Timespec>) -> io::Result<Event> {
syscalls::port_get(port.as_fd(), timeout)
}
/// `port_getn(port, events, min_events, timeout)`—Gets multiple events from /// a port. /// /// If `events` is empty, this does nothing and returns immediately. /// /// To query the number of events without retrieving any, use [`getn_query`]. /// /// If an unsupported timeout is passed, this function fails with /// [`io::Errno::INVAL`]. /// /// # References /// - [OpenSolaris] /// - [illumos] /// /// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_getn/ /// [illumos]: https://illumos.org/man/3C/port_getn #[doc(alias = "port_getn")] pubfn getn<Fd: AsFd, Buf: Buffer<Event>>(
port: Fd, mut events: Buf,
min_events: u32,
timeout: Option<&Timespec>,
) -> io::Result<Buf::Output> { // SAFETY: `port_getn` behaves. let nevents = unsafe { syscalls::port_getn(port.as_fd(), events.parts_mut(), min_events, timeout)? }; // SAFETY: `port_getn` behaves. unsafe { Ok(events.assume_init(nevents)) }
}
/// `port_getn(port, NULL, 0, NULL)`—Queries the number of events /// available from a port. /// /// To retrieve the events, use [`getn`]. /// /// # References /// - [OpenSolaris] /// - [illumos] /// /// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_getn/ /// [illumos]: https://illumos.org/man/3C/port_getn #[doc(alias = "port_getn")] pubfn getn_query<Fd: AsFd>(port: Fd) -> io::Result<u32> {
syscalls::port_getn_query(port.as_fd())
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.