#http #serde #deserialize #status #url

http-serde

Serde support for the http crate. (De)serialize HeaderMap, Uri, Method, StatusCode

2 stable releases

1.0.1 Mar 15, 2020
1.0.0 Feb 9, 2020

#435 in Encoding

Download history 1897/week @ 2021-01-10 1905/week @ 2021-01-17 2408/week @ 2021-01-24 2712/week @ 2021-01-31 2903/week @ 2021-02-07 3124/week @ 2021-02-14 2685/week @ 2021-02-21 3064/week @ 2021-02-28 2354/week @ 2021-03-07 2745/week @ 2021-03-14 2478/week @ 2021-03-21 2826/week @ 2021-03-28 2533/week @ 2021-04-04 2759/week @ 2021-04-11 2958/week @ 2021-04-18 2841/week @ 2021-04-25

9,140 downloads per month
Used in 8 crates (3 directly)

Apache-2.0 OR MIT

12KB
209 lines

Serde support for the HTTP crate

Adds ability to serialize and deserialize types from the HTTP crate.

If you want to serialize Request or Response, use into_parts() and serialize their parts, and then rebuild them using their Builder.

Usage

You must annotate fields with #[serde(with = "http_serde::<appropriate method>")].

#[derive(Serialize, Deserialize)]
struct MyStruct {
    #[serde(with = "http_serde::method")]
    status: Method,

    #[serde(with = "http_serde::status")]
    status: StatusCode,

    #[serde(with = "http_serde::uri")]
    uri: Uri,

    #[serde(with = "http_serde::header_map")]
    headers: HeaderMap,
}

Requirements

Tested with Rust 1.41.


lib.rs:

Adds ability to serialize and deserialize types from the HTTP crate.

If you want to serialize Request or Response, use into_parts() and serialize their parts, and then rebuild them using their Builder.

Usage

You must annotate fields with #[serde(with = "http_serde::<appropriate method>")].

#[derive(Serialize, Deserialize)]
struct MyStruct {
    #[serde(with = "http_serde::method")]
    status: Method,

    #[serde(with = "http_serde::status")]
    status: StatusCode,

    #[serde(with = "http_serde::uri")]
    uri: Uri,

    #[serde(with = "http_serde::header_map")]
    headers: HeaderMap,
}

Dependencies

~1–1.6MB
~35K SLoC