seredies is a mostly faithful serde implementation of RESP. This means that
it (mostly) doesn’t try to go above and beyond what the RESP data model can
express, which is mostly strings, integers, and arrays. In particular it’s not
capable of deserializing structs, maps, or complex enums. Instead,
provides a collection of components, which translate
common patterns into Redis’s minimal data model. This ensures that developers
should never be surprised by the deserializer trying to do something
unexpectedly “clever”, but can opt-in to more streamlined behavior.
bool(treated as an integer 0 or 1).
- All integers (though note that RESP only supports integers in the signed 64 bit range).
- Unit (treated as null).
- Sequences, tuples, and tuple structs.
- Bytes and string types.
- See the RedisString component for a wrapper type that converts any primitive value to or from a Redis string.
- RESP is totally binary safe, so it’s easy to deserialize
&strand other borrowed data from the payload.
Option: similar to JSON, an
Optionis handled as either a null or as an untagged value
- Unit variants: these are encoded as strings.
- Consider RedisString for the common case that Redis is treating your float data as a string.
- Maps, structs, complex enums.
- Consider KeyValuePairs for the common case that your key-value data is being treated by Redis as a flattened array of key-value pairs.
If you’re trying to serialize a Redis command, consider additionally using the Command component; it handles converting all of the command data into a list of strings, using conventions that follow the typical redis command conventions.
RESP includes an error type, which is delivered in the response when
something has gone wrong. By default, when deserializing, this error type
is treated as a deserialize error, and appears as the
Error::Redis variant when encountered. However,
you can handle them by (de)serializing a
Result directly; in this case,
Ok variant will contain the data, and a successfully (de)serialized
Err variant will contain a redis error.
Additionally, seredies ubiquitously uses the simple string “OK” to signal an
uninteresting success. This pattern is so common that
(de)serializing it directly to an
- Helper components implementing common Redis and Rust patterns.
- Serde deserializer for turning Redis RESP data into Rust data structures.
- Serde serializer for turning Rust data structures into RESP encoded data.