Crate hyper_serde [] [src]

This crate provides wrappers and convenience functions to make Hyper and Serde work hand in hand.

Currently, only two types are supported: hyper::header::Headers and hyper::method::Method.

How do I use a data type with a Headers member with Serde?

Use the serde attributes deserialize_with and serialize_with.

struct MyStruct {
    #[serde(deserialize_with = "hyper_serde::deserialize",
            serialize_with = "hyper_serde::serialize")]
    headers: Headers, 
}

How do I encode a Headers value with serde_json::to_string?

Use the Ser wrapper.

serde_json::to_string(&Ser::new(&headers))

How do I decode a Method value with serde_json::parse?

Use the De wrapper.

serde_json::parse::<De<Method>>("\"PUT\"").map(De::into_inner)

Structs

De

A wrapper to deserialize Hyper types. A This is useful with functions such as serde_json::from_str.

Ser

A wrapper to serialize Hyper types.

Functions

deserialize

Deserialises a T value with a given deserializer.

serialize

Serialises value with a given serializer.