Open dj8yfo opened 7 months ago
original motivation to create this issue was kind of resolved by https://github.com/LedgerHQ/ledger-device-rust-sdk/pull/155, but the heap on the device was still not quite usable on the device with smallest capabilities, as mentioned in comment
With the mentioned tiniest target platform being a concrete example of environment imposing specific requirements, most likely an endeavor to resolve this issue will only make sense together with changing the signature of BorshDeserialize
:
fn deserialize(...) -> Result<Self>;
to
fn deserialize(..., &mut self) -> Result<()>;
While working on an embedded app, it was discovered, that it's not possible to use
borsh
crate whenglobal_allocator
is not defined. One possible solution in such cases is to defineglobal_allocator
, another is to extractalloc
feature and to useborsh
withdefault_features = false
.Below is superficial description of changes required:
alloc
crate into separate featureborsh/src/nostd_io.rs
or make 2 variants, depending onalloc
featureBorshDeserialize
trait methodvec_from_reader
depending onalloc
featurestd::io::Error::new
andborsh::io::Error::new
implies depending onalloc
feature, there's around 50 occurencies of it inborsh
BorshSerialize
unstable__schema
feature implyalloc
featureFor reference an example of replicating a subset of
borsh
without dependency onalloc
crate is provided.