You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+45Lines changed: 45 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,51 @@ We should be able to serve the three use cases listed above, while:
71
71
<!-- TODO: Uncomment when there is work in progress -->
72
72
<!-- ### Work in progress -->
73
73
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.
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
*[`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.
*[`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
+
74
119
# Not Yet Awesome Item Template
75
120
76
121
Here's an example for something that is not yet awesome:
0 commit comments