A rust crate to parse bare ComicInfo xml files.
Find a file
Daniel Barenholz 5203498dc0
All checks were successful
Build / build (push) Successful in 31s
Release / release (push) Successful in 42s
Roundtrip tests, convenience function tests, bug fixes, and documentation updates. (#3)
This larger PR adds in a bunch of testing code, and updates the existing documentation.

Specifically, it adds:
- Roundtrip tests for serializing and deserializing `ComicInfo` structs. The implementation of those don't use `quickcheck`, but rather explicitly written `generate_XXX` functions in `mod tests`.
- Generated tests for the "convenience" functions (e.g. `add_many_writers`). These are made with a macro, similar to how the functions themselves are made with a macro.
- Relevant documentation for the above 2 points

It changes:
- The "set-esque" fields on `ComicInfo` structs are now `Option<IndexSet<String>>` so deserializing them is easier.

It fixes:
- Bugs in (de-)serialization logic.
- Bugs in percent-encoding logic (for the `Web` field).

Co-authored-by: Daniel Barenholz <hello@dbarenholz.com>
Reviewed-on: #3
2025-11-30 21:37:58 +01:00
.forgejo/workflows Add CI workflows (#1) 2025-11-19 16:12:47 +01:00
src Roundtrip tests, convenience function tests, bug fixes, and documentation updates. (#3) 2025-11-30 21:37:58 +01:00
.gitignore feat: Add comicinfo versions 1.0, 2.0, and 2.1 specs 2025-11-18 17:52:43 +01:00
Cargo.lock Roundtrip tests, convenience function tests, bug fixes, and documentation updates. (#3) 2025-11-30 21:37:58 +01:00
Cargo.toml Roundtrip tests, convenience function tests, bug fixes, and documentation updates. (#3) 2025-11-30 21:37:58 +01:00
LICENSE fix+docs: Fix incorrect assumption about serde-xml-rs usage 2025-11-18 20:49:00 +01:00
README.md Roundtrip tests, convenience function tests, bug fixes, and documentation updates. (#3) 2025-11-30 21:37:58 +01:00

comicinfo

A tiny Rust crate to parse ComicInfo.xml files.

Installation

Once available on crates.io, use cargo to add this to your project: cargo add comicinfo There are no feature flags.

Usage

The default version for the comicinfo spec is 2.1 (Draft), which is probably what you want.

use comicinfo::ComicInfo; // refers to the default version

let xml = std::fs::read_to_string("ComicInfo.xml")?;
let comicinfo = ComicInfo::from_str(&xml)?;
println!("Series: {}", info.series.unwrap_or_default());

Otherwise, import a specific version of the spec

use comicinfo::v2_0::ComicInfo; // explicitly use version 2.0

let xml = std::fs::read_to_string("ComicInfo.xml")?;
let comicinfo = ComicInfo::from_str(&xml)?;
println!("Series: {}", info.series.unwrap_or_default());

Please see the examples on the docs site for more details.

Dependencies

We depend on serde with the derive feature flag, and serde-xml-rs to make serde available for xml files. Internally we use indexset for collections on ComicInfo objects, and have a macro that requires paste to generate setters/getters and convenience methods. For property testing we need something that can generate random stuff, so we use rand.