Crates.io | gedcomx |
lib.rs | gedcomx |
version | |
source | src |
created_at | 2021-05-31 13:46:18.689 |
updated_at | 2024-10-31 18:38:54.035358 |
description | The core data structures and serialization / deserialization of the GEDCOM X format. |
homepage | |
repository | https://github.com/ephraimkunz/gedcomx-rs/tree/main/gedcomx |
max_upload_size | |
id | 404232 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
The core data structures and serialization / deserialization of the GEDCOM X format.
This crate provides conformance to the following GEDCOM X specs:
Add this to your Cargo.toml:
[dependencies]
gedcomx = "0.1"
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);
See the Design Doc for more information about why various choices were made. PRs welcome!