| Crates.io | asyncfd |
| lib.rs | asyncfd |
| version | 0.1.3 |
| created_at | 2024-12-22 23:02:44.925504+00 |
| updated_at | 2025-06-19 18:18:30.543527+00 |
| description | Send and receive file descriptors over Unix domain sockets while maintaining Tokio AsyncRead and AsyncWrite |
| homepage | |
| repository | https://github.com/chrisstaite/asyncfd/ |
| max_upload_size | |
| id | 1492348 |
| size | 59,666 |
This crate wraps the complexities of sending and receiving file descriptors over Unix domain sockets while performing asynchronous reading and writing on the socket at the same time.
See the examples directory.
# Cargo.toml
[dependencies]
asyncfd = "0.1.0"
There's no type information sent, so converting the RawFd back to a typed file descriptor is
an inherently unsafe operation.
Message headers can become concatenated within the kernel. It is highly recommended to have a handshake between the two communicating processes to ensure that the file descriptors do not get mixed up. This crate does its best to maintain file descriptor send/receive ordering.
Both of these crates use dummy data to pass file descriptors, whereas this crate performs the file descriptor passing as a side channel to the standard read/write of the socket. With the wrapper provided in this crate, the socket can simply be used by Tokio in a normal way but the implementor can add and take file descriptors depending on the sent message.
This implementation supports Tokio, but does not take ownership of the RawFds and as such cannot
provide the AsyncRead and AsyncWrite traits meaning that much more boiler plate is required
by a use of this crate.
This project is licensed with the Apache v2.