ocaml-multicore / eio

Effects-based direct-style IO for multicore OCaml
Other
528 stars 67 forks source link

Extending eio from the outside #725

Open xeniarose opened 2 months ago

xeniarose commented 2 months ago

i'm interested in implementing support for serial ports on eio, but after spending a lot of time trying to get this started and exploring the eio codebase it seems like the current state of eio makes this unreasonably difficult

for example:

what's the recommended approach here? would a hypothetical tty/serial subsystem be better served being part of eio directly? or could eio just expose a bit more of the platform-specific internals to outside libraries?

talex5 commented 2 months ago

It's not very obvious, but you can use import_socket_stream to wrap an FD as a flow.

Exposing Eio_linux.get_dir_fd_opt seems reasonable to me. Possibly we should always pass O_NOCTTY when opening things (there's a Rust issue for this at https://github.com/rust-lang/rust/issues/24307 but it got closed with no clear conclusion).