smol-rs / async-fs

Async filesystem primitives
Apache License 2.0
131 stars 8 forks source link

Is File::from_raw_fd() support possible? #3

Closed nazar-pc closed 4 years ago

nazar-pc commented 4 years ago

I'm writing a library that communicates with worker process using file descriptor. So in order to send and receive messages I'm creating files with File::from_raw_fd().

My understanding of this topic is very limited at the moment, so hopefully what I wrote makes sense :slightly_smiling_face:

ghost commented 4 years ago

Note that you can create a regular std::fs::File and then convert it into async_fs::File with .into() or async_fs::File::from(file).

But, it would also be possible to implement FromRawFd for async_fs::File if that helps. And, we could also add async fn into_inner() that converts it back into std::fs::File. What do you think?

nazar-pc commented 4 years ago

File::from() worked (compiled at least). I do think it would be useful to have direct equivalents of additional APIs in the future as you've mentioned.

P.S. Your async-* crates are so pleasant to work with! :heart:

ghost commented 4 years ago

v1.3.0 now has File::from_raw_fd()