4 ms·
Lower-level APIs like this are usually unsafe, with second-level libraries providing the safe abstractions over them.
by mmastrac 6y ago
Lower-level APIs like this are usually unsafe, with second-level libraries providing the safe abstractions over them.
- deleted 6y ago[deleted]
- MaxBarraclough 6y agoSomeone replied and then deleted their comment, but I'll reply to it anyway. They wrote: > This is the safe abstraction! I mean it's a pretty mechanical translation but it's nonetheless as safe as Rust will ever consider it. No, it's not safe. Assuming I understand Rust correctly: if your bindings allow Rust programmers to trigger undefined behaviour even when they restrict themselves to the safe subset of Rust, that means that either your bindings have a defect, or the underlying (wrapped) library has a defect.
- mmastrac 6y agoYes, exactly. It'll be pretty unlikely that raw API bindings can be made safe (even for APIs that just take raw integer handles - you could double-close one and cause corruption/etc).
- simias 6y agoI've seen some discussions on HN in the past where some rustaceans have argued that it's fine to expose raw C APIs in Rust using safe interfaces even if they're fundamentally unsound. I fail completely to understand the reasoning behind that (and I've really tried) but apparently it's still an open debate to some extent.
- MaxBarraclough 6y agoHow disappointing.