#url #serde #type #rust-url

url_serde

Serde support for URL types

5 releases

Uses old Rust 2015

0.2.0 Apr 30, 2017
0.1.3 Feb 20, 2017
0.1.2 Feb 19, 2017
0.1.1 Feb 9, 2017
0.1.0 Jan 28, 2017

#467 in #url

Download history 2713/week @ 2024-05-22 3904/week @ 2024-05-29 3748/week @ 2024-06-05 2989/week @ 2024-06-12 3383/week @ 2024-06-19 2929/week @ 2024-06-26 2386/week @ 2024-07-03 3464/week @ 2024-07-10 3208/week @ 2024-07-17 2758/week @ 2024-07-24 3026/week @ 2024-07-31 3394/week @ 2024-08-07 2788/week @ 2024-08-14 3278/week @ 2024-08-21 3131/week @ 2024-08-28 2904/week @ 2024-09-04

12,906 downloads per month
This crate has lost popularity

MIT/Apache

225KB
4K SLoC

Serde support for rust-url types

This crate provides wrappers and convenience functions to make rust-url and serde work hand in hand.

Version 0.2 or newer of this crate offer support for serde 1.0. Version 0.1 of this crate offer support for serde 0.9. Versions of serde older than 0.9 are natively supported by rust-url crate directly.

For more details, see the crate documentation.


lib.rs:

This crate provides wrappers and convenience functions to make rust-url and Serde work hand in hand.

The supported types are:

  • url::Url

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

Use the serde attributes deserialize_with and serialize_with.

#[derive(serde::Serialize, serde::Deserialize)]
struct MyStruct {
#[serde(with = "url_serde")]
url: Url,
}

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

Use the Ser wrapper.

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

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

Use the De wrapper.

serde_json::from_str(r"http:://www.rust-lang.org").map(De::into_inner)

How do I send Url values as part of an IPC channel?

Use the Serde wrapper. It implements Deref and DerefMut for convenience.

ipc::channel::<Serde<Url>>()

Dependencies

~1–1.5MB
~52K SLoC