#http #serde #deserialize #status #url

http-serde

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

6 stable releases

2.0.0 Nov 20, 2023
1.1.3 Aug 18, 2023
1.1.2 Sep 11, 2022
1.1.0 Feb 5, 2022
1.0.0 Feb 9, 2020

#82 in Encoding

Download history 50573/week @ 2023-11-07 55350/week @ 2023-11-14 44799/week @ 2023-11-21 50078/week @ 2023-11-28 49791/week @ 2023-12-05 50791/week @ 2023-12-12 43806/week @ 2023-12-19 27092/week @ 2023-12-26 53547/week @ 2024-01-02 56196/week @ 2024-01-09 60570/week @ 2024-01-16 63940/week @ 2024-01-23 63487/week @ 2024-01-30 61622/week @ 2024-02-06 69526/week @ 2024-02-13 56596/week @ 2024-02-20

262,277 downloads per month
Used in 154 crates (45 directly)

Apache-2.0 OR MIT

16KB
279 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")]
    method: Method,

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

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

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

    #[serde(with = "http_serde::authority")]
    authority: Authority,
}

Requirements

  • Rust 1.41 or later.

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")]
    method: Method,

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

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

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

    #[serde(with = "http_serde::authority")]
    authority: Authority,
}

Dependencies

~1–1.6MB
~34K SLoC