oconnor663 / os_pipe.rs

a cross-platform library for opening OS pipes in Rust
MIT License
100 stars 16 forks source link

enh request: Implement async read/write traits #30

Open rbtcollins opened 10 months ago

rbtcollins commented 10 months ago

e.g. AsyncRead, AsyncBufRead etc. This would require a dependency on futures, so perhaps a feature flag. Wouldn't need to bring in tokio or anything large, and as far as I can tell aligns well with the intent of a mid-layer crate.

rbtcollins commented 10 months ago

(Converting via tokio's asyncfd support isn't possible today, because there is no anonymous Pipe layer today, only unix fd's and windows NamedPipes. Another route forward would be to switch to namedpipes.

https://docs.rs/tokio/latest/tokio/io/unix/struct.AsyncFd.html?search=asyncfd

NobodyXu commented 10 months ago

imo there's tokio-pipe for tokio

rbtcollins commented 10 months ago

@NobodyXu oh, thank you, will give that a go, but its not a like-for-like drop in as I can see: it requires unsafe and bouncing through asrawfd / from rawfd - which os_pipe can be used this way as well - nothing like the ergonomics of os_pipe for std::process:Command.

NobodyXu commented 10 months ago

@rbtcollins which function is missing?

There's a pipe() for creating pipes, though there isn't a try_clone() function.

Do you need try_clone()?

It should be very easy to add that support to the crate.