7 releases (2 stable)

1.1.0 Jun 17, 2020
1.0.0 Jun 11, 2020
0.4.0 Jun 3, 2019
0.3.1 Oct 11, 2018
0.1.0 Feb 9, 2018

#127 in Encoding

Download history 138040/week @ 2024-07-20 134995/week @ 2024-07-27 140415/week @ 2024-08-03 136385/week @ 2024-08-10 149584/week @ 2024-08-17 148221/week @ 2024-08-24 148405/week @ 2024-08-31 144299/week @ 2024-09-07 139685/week @ 2024-09-14 155636/week @ 2024-09-21 157342/week @ 2024-09-28 161037/week @ 2024-10-05 165345/week @ 2024-10-12 178530/week @ 2024-10-19 158382/week @ 2024-10-26 173127/week @ 2024-11-02

703,715 downloads per month
Used in 328 crates (92 directly)

MIT/Apache

18KB
440 lines

Serde Regex

Documentation | Github | Crate

A serde wrapper, that can be used to serialize regular expressions as strings. It's often useful to read regexes from configuration file.

Note: regex is read with default settings. So DoS attack is probably possible if reading regex from untrusted source. I.e. reading from config file is okay, reading from API request is not.

Example

#[macro_use]
extern crate serde_derive;

extern crate serde;
extern crate serde_regex;

use regex::Regex;

#[derive(Serialize, Deserialize)]
struct Timestamps {
    #[serde(with = "serde_regex")]
    pattern: Regex,
}

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2.2–3.5MB
~61K SLoC