#regex #regular

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

#136 in Encoding

Download history 133540/week @ 2024-06-14 136121/week @ 2024-06-21 117911/week @ 2024-06-28 113766/week @ 2024-07-05 115415/week @ 2024-07-12 135262/week @ 2024-07-19 134199/week @ 2024-07-26 139072/week @ 2024-08-02 140721/week @ 2024-08-09 145600/week @ 2024-08-16 147358/week @ 2024-08-23 147031/week @ 2024-08-30 147065/week @ 2024-09-06 138202/week @ 2024-09-13 155835/week @ 2024-09-20 126381/week @ 2024-09-27

596,913 downloads per month
Used in 315 crates (90 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.3–3.5MB
~62K SLoC