Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit f0c9a8d

Browse files
authored
Merge pull request #10 from rust-embedded/no_std-serialization
Add NYAER for serialization and deserialization
2 parents 30eda89 + 22b5ad0 commit f0c9a8d

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,51 @@ We should be able to serve the three use cases listed above, while:
7171
<!-- TODO: Uncomment when there is work in progress -->
7272
<!-- ### Work in progress -->
7373

74+
## Serialization/Deserialization in `no_std`
75+
76+
### Background
77+
78+
For embedded systems that send or receive data to other devices, or who read/write data to a medium such as an SD card or other Flash memory, it is useful to have automatic serialization and deserialization support to turn structured data into a binary format.
79+
80+
While tools like [`serde`] are widely used in Rust (and already support `no_std`), few of the the backends (like [`serde_json`]) are supported in a `no_std` environment.
81+
82+
[`serde`]: https://github.com/serde-rs/serde
83+
[`serde_json`]: https://github.com/serde-rs/json
84+
[`ssmarshal`]: https://gitlab.com/robigalia/ssmarshal
85+
[`ujson`]: https://github.com/japaric/jnet/tree/master/ujson
86+
[`bincode-no-std`]: https://github.com/losfair/bincode
87+
[`cbor-no-std`]: https://crates.io/crates/cbor-no-std
88+
89+
### Success Criteria
90+
91+
We should be able to serialize and deserialize data in an automatic way, either using a frontend like [`serde`], or with a simple and convenient `serialize` and `deserialize` method. To use these, we should not need heap allocations, and it should be possible to detect when serialization and deserialization have failed.
92+
93+
Additionally, all common datatypes used in embedded Rust should be supported, as well as a (preferrably automatic) way to add support for custom data types. Common data types include:
94+
95+
* Fixed point signed/unsigned numbers like `u8..u64` or `i8..i64`
96+
* Floating point numbers like `f32..f64`
97+
* Booleans
98+
* Variable length types, like `[u8]` and `&str`
99+
* Tuples
100+
* Enumerated types
101+
102+
We should also have support for different ways of serializing data, primarily:
103+
104+
* Self-describing schemas, such as JSON or CBOR
105+
* Non-self-describing schemas, such as binary packed data or ProtoBufs
106+
107+
### Work in progress
108+
109+
* [`serde`] already has support for `no_std` environments, when using a feature flag
110+
* Serde welcomes [contributions](https://github.com/serde-rs/json/blob/master/CONTRIBUTING.md)
111+
* [`ssmarshal`] has support for basic types, but does not support enums with more than 255 variants, or variable sized types like slices. This covers only the non-self-describing use case.
112+
* ssmarshal welcomes [contributions](https://gitlab.com/robigalia/ssmarshal/blob/master/CONTRIBUTING.md)
113+
* [`ujson`] supports JSON serialization and deserialization for `no_std` environments, but is experimental (and not on crates.io), and is unlikely to be stabilized as-is
114+
* It is unknown if ujson welcomes contributions
115+
* There are a number of forks of `std`-only `serde` backends, though they do not seem to have official support from the upstream libraries. These forks include:
116+
* [`bincode-no-std`]
117+
* [`cbor-no-std`]
118+
74119
# Not Yet Awesome Item Template
75120

76121
Here's an example for something that is not yet awesome:

0 commit comments

Comments
 (0)