Comment by Nursie
3 years ago
> One of the interesting patterns happening in Rust is io-less libraries.
Not to join in too much on the "but we already had this!" bandwagon ... but actually to join in the bandwagon - we had these sorts of patterns in C 20 years ago. I worked with a TLS implementation like this sometime around 2005.
Either you work with buffer-in/buffer-out types of scenario, or you register callbacks to do the real IO.
It's a great pattern and means that you can do stuff like change transport mechanism, or put in proxying, or whatever you want really, without having to change the library.
With embedded C stuff it was also relatively common to handle memory allocation this way - buy in a library that does whatever proprietrary thing you need from a vendor, then register your custom allocator with it so when it needed heap memory, you could provide that in line with whatever platform restrictions you had going.
No comments yet
Contribute on Hacker News ↗