Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vstroebel/de-regex
Regular expression based deserialization for serde
https://github.com/vstroebel/de-regex
regular-expression rust serde
Last synced: 4 days ago
JSON representation
Regular expression based deserialization for serde
- Host: GitHub
- URL: https://github.com/vstroebel/de-regex
- Owner: vstroebel
- License: apache-2.0
- Created: 2021-04-29T09:43:47.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-23T13:01:11.000Z (over 2 years ago)
- Last Synced: 2025-01-20T09:40:16.788Z (15 days ago)
- Topics: regular-expression, rust, serde
- Language: Rust
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# De-Regex
[![docs.rs badge](https://docs.rs/de-regex/badge.svg)](https://docs.rs/de-regex/)
[![crates.io badge](https://img.shields.io/crates/v/de-regex.svg)](https://crates.io/crates/de-regex/)
[![Rust](https://github.com/vstroebel/de-regex/actions/workflows/rust.yml/badge.svg)](https://github.com/vstroebel/de-regex/actions/workflows/rust.yml)This crate contains a library that deserializes a string into a struct based on a regular expression and serde.
## Example
```rust
use serde::Deserialize;#[derive(Deserialize)]
struct Dimensions {
width: u32,
height: u32
}let pattern = r"^(?P\d+)x(?P\d+)$";
let input = "800x600";let dim: Dimensions = de_regex::from_str(input, pattern).unwrap();
assert_eq!(dim.width, 800);
assert_eq!(dim.height, 600);
```## License
This project is licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in de-regexp by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.