Expand description
§GEDCOM X
GEDCOM X defines an open data model and an open serialization format for exchanging the genealogical data essential to the genealogical research process. Examples of these data include information about persons, the relationships between persons, and the records that support that information.
This library provides the base types necessary to implement the GEDCOM X conceptual model and aims to implement further extensions to this model in the future. The goal of the library is to provide a correct, hard-to-misuse API that can handle serialization / deserialization to and from both JSON and XML. It’s intended to be a solid foundational building block that other genealogical software can be built on top of.
§Examples
§Deserialize a GEDCOM X document from JSON
use gedcomx::Gedcomx;
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);
§Build and serialize a GEDCOM X document to JSON
Most of the GEDCOM X types have lots of properties. Builders are provided
for most types to conveniently set only the properties you choose to.
Builders can be created with the builder
method on the specific type. This
method will take any required argument the final type needs to have set.
Other properties can then be set on the builder. After the builder has been
fully configured, it can be transformed into an instance of the type it is
building by calling the build
method on it.
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);
§Deserialize a GEDCOM X document from XML
use gedcomx::Gedcomx;
let xml = std::fs::read_to_string("../data/birth.xml").unwrap();
let gx = Gedcomx::from_xml_str(&xml).unwrap();
println!(
"Successfully deserialized GEDCOM X document from XML with {} people inside!",
gx.persons.len()
);
assert_eq!(gx.persons.len(), 4);
§Build and serialize a GEDCOM X document to XML
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 xml = gx.to_xml_string_pretty().unwrap();
assert_eq!(xml.len(), 277);
Re-exports§
pub extern crate gedcomx_date;
Modules§
Structs§
- Address
- A street or postal address of a person or organization.
- Address
Builder - Agent
- Someone or something that curates genealogical data, such as a genealogical researcher, user of software, organization, or group.
- Agent
Builder - Attribution
- The data structure used to attribute who, when, and why to genealogical data.
- Attribution
Builder - Coverage
- The coverage of a resource.
- Date
- A concluded genealogical date.
- Document
- The base conceptual model for genealogical data that are managed as textual documents.
- Document
Builder - Event
- A description of a historical event.
- Event
Builder - Event
Role - A role played in an event by a person.
- Event
Role Builder - Evidence
Reference - A reference to data being used to derive the given instance of Subject.
- Fact
- A data item that is presumed to be true about a specific subject, such as a person or relationship.
- Fact
Builder - Gedcomx
- A container for a set of GEDCOM X data. The top level type in the library.
- Gedcomx
Builder - Gedcomx
Date - Newtype wrapping
GedcomxDate
from thegedcomx_date
crate. - Gender
- A gender of a person.
- Gender
Builder - Group
- A group of of persons.
- Group
Builder - Group
Role - A role of a person in a group.
- Group
Role Builder - Id
- A local, context-specific id for the data.
- Identifier
- An identifier of a genealogical resource.
- Lang
- Defined by IETF BCP 47.
- Name
- A name of a person.
- Name
Builder - Name
Form - A representation of a name (a “name form”) within a given cultural context, such as a given language and script.
- Name
Form Builder - Name
Part - A portion of a full name, including the terms that make up that portion.
- Name
Part Builder - Note
- A note that was contributed from genealogical research.
- Note
Builder - Online
Account - A description of an account for an online service provider.
- Person
- A description of a person.
- Person
Builder - Place
Description - Describes the details of a place in terms of its name and possibly its type, time period, and/or a geospatial description – functioning as a description of a place as a snapshot in time.
- Place
Description Builder - Place
Reference - A reference to a description of a place.
- Place
Reference Builder - Qualifier
- Used to supply additional details, annotations, tags, or other qualifying data to a specific data element.
- Relationship
- A relationship between two persons.
- Relationship
Builder - Resource
Reference - A generic reference to a resource.
- Source
Citation - A container for the metadata necessary for an agent to identify a source(s).
- Source
Description - A description of a source of genealogical information.
- Source
Description Builder - Source
Reference - A reference to a source description.
- Source
Reference Builder - Text
Value - An element representing a text value that may be in a specific language.
- Timestamp
- When an event something was created or modified.
- Uri
- Specified by RFC 3986.
Enums§
- Confidence
Level - Levels of confidence.
- Document
Type - Document types
- Event
Role Type - Standard event roles.
- Event
Type - Standard event types.
- Fact
Qualifier - Fact qualifiers.
- Fact
Type - Standard fact types.
- Gedcomx
Error - An error returned by the library.
- Gender
Type - Type of gender.
- Group
Role Type - Group role types.
- Identifier
Type - Standard identifier types. Custom identifier types should not have a value of “$” since this is reserved for identifiers without a type in JSON.
- Name
Part Qualifier - Name part qualifiers.
- Name
Part Type - Standard name part types.
- Name
Type - Standard name types.
- Relationship
Type - Standard relationship types.
- Resource
Type - Standard resource types.
- Source
Reference Qualifier - Source reference qualifiers.
- Text
Type - The styling or layout of type of text.