mirror of
https://github.com/NLnetLabs/domain.git
synced 2026-09-26 19:54:54 +02:00
This commit completely redesigns zone file parsing. The primary change is to convert the scanner into a trait in order to allow multiple zone parser implementations for different sources and purposes. A number of changes had to be made in order to make this possible. The commit also contains an initial implementation of a scanner that modifies data in-place and can thus returned parsed data with only a minimal amount of additional allocations. While working, this scanner is more a proof-of-concept at this point to ensure that the API design is sound. This commit is based on ideas and code proposed by @not-my-profile in #106. This commit increases the minimal supported Rust version to 1.59.0.
35 lines
980 B
Rust
35 lines
980 B
Rust
//! Reads a zone file.
|
|
|
|
fn main() {
|
|
use domain::zonefile::inplace::Zonefile;
|
|
use std::env;
|
|
use std::fs::File;
|
|
use std::time::SystemTime;
|
|
|
|
for arg in env::args().skip(1) {
|
|
print!("Processing {}: ", arg);
|
|
let start = SystemTime::now();
|
|
let mut zone = Zonefile::load(&mut File::open(arg).unwrap()).unwrap();
|
|
println!(
|
|
"Data loaded ({:.03}s).",
|
|
start.elapsed().unwrap().as_secs_f32()
|
|
);
|
|
let mut i = 0;
|
|
while let Some(_) = zone.next_entry().unwrap() {
|
|
i += 1;
|
|
if i % 100_000_000 == 0 {
|
|
eprintln!(
|
|
"Processed {}M records ({:.03}s)",
|
|
i / 1_000_000,
|
|
start.elapsed().unwrap().as_secs_f32()
|
|
);
|
|
}
|
|
}
|
|
eprintln!(
|
|
"Complete with {} records ({:.03}s)\n",
|
|
i,
|
|
start.elapsed().unwrap().as_secs_f32()
|
|
);
|
|
}
|
|
}
|