#serde #regex

serde_regex

A serde wrapper that (de)serializes regex as strings

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

#159 in Encoding

Download history 27470/week @ 2021-08-08 23640/week @ 2021-08-15 22861/week @ 2021-08-22 23018/week @ 2021-08-29 18641/week @ 2021-09-05 18837/week @ 2021-09-12 27445/week @ 2021-09-19 21508/week @ 2021-09-26 38398/week @ 2021-10-03 49375/week @ 2021-10-10 54808/week @ 2021-10-17 48235/week @ 2021-10-24 55879/week @ 2021-10-31 46120/week @ 2021-11-07 40756/week @ 2021-11-14 42048/week @ 2021-11-21

28,961 downloads per month
Used in 74 crates (24 directly)

MIT/Apache

17KB
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

~1.1–1.6MB
~44K SLoC

^