Postcard Bindgen
The postcard crate serializes and deserializes rust structs by using the serde crate to a byte format. The resulting byte size is minimal. This is very useful if serialization and deserialization is done in rust and share the same structures.
This crate can generate bindings from the rust structures for other languages than rust. This allows to use the postcard crate from other languages.
Crateis work in progress. By now it can't be used for productions.
Supported languages
- JavaScript
- Python
Usage
The structs for which bindings should be generated must be annotated with the PostcardBindings macro. This macro understands serde annotation. This means renaming fields and other functionality by serde is supported.
Example
JavaScript Type mapping
;
;
;
;
;
;
// OptionTuple(Some(123))
// OptionTuple(None)
// OptionStruct { a: Some(123) }
// OptionStruct { a: None }
// or
let map_string_key = new;
let map_any_key = new;
// map_string_key
// map_any_key