Expose read_with & similar
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 339
- PR merge metrics
- No merged PRs in 30d
Description
On an async_std::net::UdpSocket I occasionally need to `recvmsg`. This is not exposed by async_std, and would barely be a reasonable request, given that std doesn't expose it either.
It is well available through `nix` (where it is placed well), but accessing it through brings the need to get informed on a read. A naive approach would be asking for access to the watcher -- then it'd be straightforward to do `socket.watcher.read_with(|s| nix::...::recvmsg(s.as_raw_fd(), ...).await`, but that was amply discussed in #293 and found not to be a good idea.
There was the idea around to expose only `.watcher.read_with()` as an own `.read_with()`, which would be more independent of the underlying implementation (it would be trivial with the watcher being as it is, and not expose any types, and at worst would need more than the one-line pass-on that it is now).
Please consider exposing some version of `.read_with()` (and probably `.write_with()` and their `_mut` variants for completeness).
I've tried working around this limitation by creating an own watcher (`async_io::async::new(socket.as_raw_fd())`), but that would register the same file descriptor twice in the epoll, dying with -EEXIST.
Contributor guide
Assessment
This issue has not been assessed yet.