anchovy
Unix sockets can carry open file descriptors alongside data, but nothing in the
standard async I/O stack handles this. In async Rust you have to drop down to
sendmsg/recvmsg yourself. anchovy handles that: it wraps a UnixStream and
implements AsyncRead/AsyncWrite with fd passing via SCM_RIGHTS ancillary
messages.
Usage
[]
= "0.4"
The const generic S is the maximum number of file descriptors a single message
can carry. Use AnchovyStream<DBUS_FD_LIMIT> for D-Bus or
AnchovyStream<WAYLAND_FD_LIMIT> for Wayland. For other protocols, set S to
the maximum number of file descriptors you expect per message.
Sending file descriptors
Push OwnedFd values into the write queue before writing. All queued
descriptors go out together in a single sendmsg call, then the queue is
cleared.
use ;
use OwnedFd;
use AsyncWriteExt;
async
Receiving file descriptors
Descriptors received with a message land in the read queue. Drain it after each read.
use ;
use AsyncReadExt;
async
Origin
waynest and abus both needed this and ended up writing the same wrapper independently. anchovy is that wrapper, extracted into a shared crate before the two implementations diverged further.
License
This project is licensed under the Apache-2.0 License. For more information, please see the LICENSE file.