15 releases
new 0.1.7 | Oct 31, 2024 |
---|---|
0.1.6 | Oct 26, 2024 |
0.1.5 | Jul 21, 2023 |
0.1.3 | Jan 18, 2022 |
0.1.0-alpha.1 | May 31, 2021 |
#308 in Parser implementations
250 downloads per month
Used in gedcomx_file
445KB
10K
SLoC
gedcomx
The core data structures and serialization / deserialization of the GEDCOM X format.
Specification Compliance
This crate provides conformance to the following GEDCOM X specs:
- GEDCOM X XML 1.0 fully implemented using Yaserde for XML serialization and deserialization.
- GEDCOM X JSON 1.0 fully implemented using Serde for JSON serialization and deserialization.
- GEDCOM X Event Types 1.0 fully implemented.
- GEDCOM X Fact Types 1.0 fully implemented.
- GEDCOM X Name Part Qualifiers 1.0 fully implemented.
- GEDCOM X Relationship Types 1.0 fully implemented.
- GEDCOM X Date 1.0 compliant via the gedcomx_date crate.
- GEDCOM X Field Types 1.0
- GEDCOM X Record Extensions 1.0
- FamilySearch GEDCOM X Extensions
- GEDCOM X Atom Extensions 1.0
- GEDCOM X RS 1.0
Features
- Well tested: hundreds of unit tests and some large integration tests. Integration tests parsing of all the recipes in the Recipe Book as well as other test data from the Java Gedcomx implementation.
- Fuzzed and quickchecked.
- Use the builder pattern to safely build GEDCOM X data models.
- XML and JSON serialization and deserialization supported.
Documentation
Usage
Add this to your Cargo.toml:
[dependencies]
gedcomx = "0.1"
Example
A GEDCOM X document can be deserialized from JSON:
use gedcomx::Gedcomx;
fn main() {
let json = std::fs::read_to_string("../data/birth.json").unwrap();
let gx = Gedcomx::from_json_str(&json).unwrap();
println!(
"Successfully deserialized GEDCOM X document from JSON with {} people inside!",
gx.persons.len()
);
assert_eq!(gx.persons.len(), 4);
}
Similarly, you can deserialize from XML with the Gedcomx struct's from_xml_str
method.
In-memory GEDCOM X documents can be built by instantiating individual components and adding them to an instance of Gedcomx
.
This can then be serialized to JSON or XML using a family of functions defined on Gedcomx
:
use gedcomx::{Gedcomx, Name, NameForm, NameType, Person};
let gx = Gedcomx::builder()
.person(
Person::builder()
.private(true)
.name(
Name::builder(
NameForm::builder()
.full_text("Jim Halpert")
.lang("en")
.build(),
)
.name_type(NameType::BirthName)
.build(),
)
.build(),
)
.build();
let json = gx.to_json_string_pretty().unwrap();
assert_eq!(json.len(), 285);
Contributing
See the Design Doc for more information about why various choices were made. PRs welcome!
Dependencies
~3.5–5MB
~99K SLoC