-
Notifications
You must be signed in to change notification settings - Fork 98
Description
This extends #181 with the ability to embed bounded strings or lists directly within other structures while maintaining the variable length property.
Some environments require avoiding all memory allocations at runtime. This happens typically in either small embedded environments or safety related products.
To achieve this in a call returning a string or list/vector you typically combine a fixed size buffer with a length indicator into a containing data structure, e.g. see heapless::String or boost::static_string.
Thus I propose to optionally extend the fixed size buffers of #181 as implemented in #384 with a preceding length indicator. This length indicator could be of type u8 for strings/vectors below 256 elements, u16 below 64k and u32 otherwise. Unused elements in the buffer should be considered uninitialized (MaybeUninit in Rust).
This addresses the problem described in my recent comment in #383 .
I propose the WIT syntax string<..32> or list<u32, ..16>, the binary format would need a new type for bounded strings, lists could use a negative len specifier in 0x67 (see #384 ) or a different defvaltype.