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;

Structs

A street or postal address of a person or organization.

Someone or something that curates genealogical data, such as a genealogical researcher, user of software, organization, or group.

The data structure used to attribute who, when, and why to genealogical data.

The coverage of a resource.

A concluded genealogical date.

The base conceptual model for genealogical data that are managed as textual documents.

A description of a historical event.

A role played in an event by a person.

A reference to data being used to derive the given instance of Subject.

A data item that is presumed to be true about a specific subject, such as a person or relationship.

A container for a set of GEDCOM X data. The top level type in the library.

Newtype wrapping GedcomxDate from the gedcomx_date crate and adding the ability to generate a formal string (via the Display trait), failably parse from a string (via the FromStr trait), and serialize and deseserialize into JSON and XML.

A gender of a person.

A group of of persons.

A role of a person in a group.

A local, context-specific id for the data.

An identifier of a genealogical resource.

Defined by IETF BCP 47.

A name of a person.

A representation of a name (a “name form”) within a given cultural context, such as a given language and script.

A portion of a full name, including the terms that make up that portion.

A note that was contributed from genealogical research.

A description of an account for an online service provider.

A description of a person.

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.

A reference to a description of a place.

Used to supply additional details, annotations, tags, or other qualifying data to a specific data element.

A relationship between two persons.

A generic reference to a resource.

A container for the metadata necessary for an agent to identify a source(s).

A description of a source of genealogical information.

A reference to a source description.

An element representing a text value that may be in a specific language.

When an event something was created or modified.

Specified by RFC 3986.

Enums

Levels of confidence.

Document types

Standard event roles.

Standard event types.

Fact qualifiers.

Standard fact types.

An error returned by the library.

Type of gender.

Group role types.

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 qualifiers.

Standard name part types.

Standard name types.

Standard relationship types.

Standard resource types.

Source reference qualifiers.

In some cases, a text value must include styling or layout to fully convey its intended meaning. Where such a requirement has been identified, implementers can designate that a text value may include such styling or layout by specifying an alternate text type.

Type Definitions