Currently there are
std::os:unix::io on unix-like systems and
RawSocket on windows and their corresponding traits, but on macOS and iOS there are no similar types/traits for Mach port handles (names). Since Mach ports are extensively used for communication with kernel and system services on these systems (most importantly for asynchronous kernel method calls) I believe supporting them on these platforms is important.
I suggest providing an abstraction for a raw Mach port handle in one central crate to prevent developers who want to provide some kind of functionality related to Mach ports from each providing their own type. This may be a simple
pub type RawMachPort = libc::c_int and a set of traits (
An example where this may be used: IOKit object handles are effectively Mach port handles, however the IOKit framework abstracts this behind a stable C API. Someone developing IOKit bindings (hi!) may want to provide the ability to extract the handle without relying on a specific crate that provides Mach interface bindings.
- Should it be in the standard library or a separate crate? Seems like Mach ports, unlike Windows handles, sockets and file descriptors aren't used in the standard library currently. On the other hand there is now a type in the standard library for raw Windows kernel object handles, however on macOS/iOS there is none.
- Should there be any other related types/traits?