https://github.com/baoyachi/eat-nom
eat nom
https://github.com/baoyachi/eat-nom
combinator ip ipmask mask nom parser rust
Last synced: about 1 month ago
JSON representation
eat nom
- Host: GitHub
- URL: https://github.com/baoyachi/eat-nom
- Owner: baoyachi
- License: mit
- Created: 2020-04-12T09:03:42.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-27T04:31:17.000Z (over 4 years ago)
- Last Synced: 2025-03-16T17:12:55.469Z (about 1 month ago)
- Topics: combinator, ip, ipmask, mask, nom, parser, rust
- Language: Rust
- Homepage:
- Size: 39.1 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eat-nom
[](
https://github.com/baoyachi/eat-nom)
[](
https://crates.io/crates/eat-nom)
[](
https://docs.rs/eat-nom)eat nom based on [nom](https://github.com/Geal/nom). A tools about normal domain extend use nom
# 《玩转nom解析引擎》
* https://www.bilibili.com/video/BV1UK4y157BP## parse ip
* parse_ip_mask
```rust
extern crate eat_nom;use eat_nom::ip::parse_ip_mask;
use std::net::Ipv4Addr;fn main() {
let ip_mask = "127.0.0.1/255.0.255.0";
let (ip, mask) = parse_ip_mask(ip_mask, "/").unwrap();
assert_eq!(ip, Ipv4Addr::new(127, 0, 0, 1));
assert_eq!(mask, Ipv4Addr::new(255, 0, 255, 0));
}
```
*# parse_ip_mask_opt
```rust
extern crate eat_nom;use eat_nom::ip::parse_ip_mask_opt;
use std::net::Ipv4Addr;fn main() {
let ip_mask = "127.0.0.1/255.0.255.0";
let (ip, mask) = parse_ip_mask_opt(ip_mask).unwrap();
assert_eq!(ip, Ipv4Addr::new(127, 0, 0, 1));
assert_eq!(mask, Ipv4Addr::new(255, 0, 255, 0));
}
```* net
* time