Skip to content

Conversation

@abhillman
Copy link

@abhillman abhillman commented Dec 31, 2025

Adds serde derivations when that feature is enabled for Record and its recursive children types. Example:

use std::fs::File;
use serde_json;
use zoneparser::ZoneParser;

fn main() {
    let file = File::open("my-zone.no").unwrap();
    let parser = ZoneParser::new(&file, "my-zone.no");
    
    // Collect all records
    let records: Vec<_> = parser.collect::<Result<Vec<_>, _>>().unwrap();
    
    // Serialize to JSON
    let json = serde_json::to_string_pretty(&records).unwrap();
    println!("{}", json);
}

Run the additional test via cargo test --features serde serde. Use the additional feature in Cargo.toml via:

cargo add zoneparser --features serde

or

zoneparser = { version = "0.1.6", features = ["serde"] }

In addition, this PR has respective commits that:

  • commit the result of cargo fmt
  • updates the bstr dep to its latest version in Cargo.toml
  • adds Cargo.lock (standard practice)
  • updates to README.md

For reviewing ease, optionally review one commit at a time.


Thanks for the nice code and for publishing it. I had written a parser earlier this year in Rust as well and like what you have done here.

@abhillman abhillman force-pushed the aryeh/add-serde-feature branch from 4f6b415 to 10f9ae0 Compare December 31, 2025 01:49
@abhillman abhillman force-pushed the aryeh/add-serde-feature branch from dc23f98 to 3478723 Compare December 31, 2025 01:50
@erikoest
Copy link
Owner

erikoest commented Jan 2, 2026

Thanks for your contribution. I'll consider adding it in. But could you please remove the 'cargo fmt' changes from your feature branch? It would make it easier to see what are the real changes that you introduce. I can rather add formatting/prettyprinting in a separate commit later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants