NuxiNL / cloudlibc

CloudABI's standard C library
BSD 2-Clause "Simplified" License
295 stars 17 forks source link

Provide writeable console implementation in the Rust library #22

Open mcandre opened 5 years ago

mcandre commented 5 years ago

The Rust tutorial for developing CloudABI programs requires the developer to write a substantial amount of unsafe code by hand in order to be able to use cloudabi::fd's with typical Rust writing functions and macros. Could we include this console write implementation in the crate by default, so that developers can use cloudabi in a more safe and convenient manner?

https://cloudabi.org/write/rust/

EdSchouten commented 5 years ago

Agreed!

When doing so, we should also keep in mind that the numbers stored in Argdata don't necessarily need to map to file descriptor numbers directly. They are merely logical indices to handles that are not part of the data.

Getting this right is essential to getting stuff like ARPC working. The message sent across the line can't make any assumptions about what the file descriptor numbers look like on the sending/receiving side, as they are dynamically allocated. It's up to the RPC framework to map the logical numbers back to file descriptor numbers.

(I have to confess I haven't been able to spend a lot of time with Rust lately. Anyone willing to take a stab at this? Would love to review, though.)