Expand description
Serialization and deserialization support.
- JSON support is provided by the
Jsontype. - MessagePack support is provided by the
MsgPacktype. - UUID support is provided by the
UUIDtype.
Types implement one or all of FromParam,
FromForm, FromData,
and Responder.
§Deriving Serialize, Deserialize
For convenience, Rocket re-exports serde’s Serialize and Deserialize
traits and derive macros from this module. However, due to Rust’s limited
support for derive macro re-exports, using the re-exported derive macros
requires annotating structures with #[serde(crate = "rocket::serde")]:
use rocket::serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
#[serde(crate = "rocket::serde")]
struct MyStruct {
foo: String,
}If you’d like to avoid this extra annotation, you must depend on serde
directly via your crate’s Cargo.toml:
[dependencies]
serde = { version = "1.0", features = ["derive"] }Modules§
- json
json - Automatic JSON (de)serialization support.
- msgpack
msgpack - Automatic MessagePack (de)serialization support.
- uuid
uuid - UUID path/query parameter and form value parsing support.
Traits§
- Deserialize
- A data structure that can be deserialized from any data format supported by Serde.
- Deserialize
Owned - A data structure that can be deserialized without borrowing any data from the deserializer.
- Deserializer
- A data format that can deserialize any data structure supported by Serde.
- Serialize
- A data structure that can be serialized into any data format supported by Serde.
- Serializer
- A data format that can serialize any data structure supported by Serde.