tink-rust
tink-rust copied to clipboard
Support `no_std` in (most) crates
First, need a version of prost that includes https://github.com/danburkert/prost/commit/fdf9fdf730e2554a6c2bce693f7600e350358c7d.
Then the obvious changes needed to make Tink no_std compatible would include the following (but there are bound to be others):
- Depend on
core+allocinstead ofstd, and have astdfeature for those things that definitely needstd:- keyset I/O (both binary and JSON-based)
- streaming AEAD
- Changes to use
core/alloctypes:Box=>alloc::boxed::BoxString=>alloc::string::StringVec=>alloc::vec::Vecstd::sync::Arc=>alloc::sync::Arcstd::fmt::*=>core::fmt::*std::collections::HashMap=>alloc::collections::BTreeMapstd::sync::RwLock=>spin::RwLockstd::convert::From=>core::convert::From- Move
TinkErrorto wrap something that just implementscore::fmt::Debugrather thanstd::error::Error.
Key question: given that alloc would definitely be required, does (no_std + alloc) really give much advantage over std?
I think in practice it's only useful for targets that do not have std yet, but somehow have alloc already. My guess is that there are not many practical cases for this. Maybe for some embedded devices based on Arm or AVR?
(Answering my own question: core + alloc works on platforms that have memory, but don't have (say) filesystems, networking, thread scheduling, etc. So yes, it does open up a bunch of potential platforms that std would exclude.)