Crate gedcomx

Source
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§

serde_vec_identifier_to_map

Structs§

Address
A street or postal address of a person or organization.
AddressBuilder
Agent
Someone or something that curates genealogical data, such as a genealogical researcher, user of software, organization, or group.
AgentBuilder
Attribution
The data structure used to attribute who, when, and why to genealogical data.
AttributionBuilder
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.
DocumentBuilder
Event
A description of a historical event.
EventBuilder
EventRole
A role played in an event by a person.
EventRoleBuilder
EvidenceReference
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.
FactBuilder
Gedcomx
A container for a set of GEDCOM X data. The top level type in the library.
GedcomxBuilder
GedcomxDate
Newtype wrapping GedcomxDate from the gedcomx_date crate.
Gender
A gender of a person.
GenderBuilder
Group
A group of of persons.
GroupBuilder
GroupRole
A role of a person in a group.
GroupRoleBuilder
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.
NameBuilder
NameForm
A representation of a name (a “name form”) within a given cultural context, such as a given language and script.
NameFormBuilder
NamePart
A portion of a full name, including the terms that make up that portion.
NamePartBuilder
Note
A note that was contributed from genealogical research.
NoteBuilder
OnlineAccount
A description of an account for an online service provider.
Person
A description of a person.
PersonBuilder
PlaceDescription
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.
PlaceDescriptionBuilder
PlaceReference
A reference to a description of a place.
PlaceReferenceBuilder
Qualifier
Used to supply additional details, annotations, tags, or other qualifying data to a specific data element.
Relationship
A relationship between two persons.
RelationshipBuilder
ResourceReference
A generic reference to a resource.
SourceCitation
A container for the metadata necessary for an agent to identify a source(s).
SourceDescription
A description of a source of genealogical information.
SourceDescriptionBuilder
SourceReference
A reference to a source description.
SourceReferenceBuilder
TextValue
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§

ConfidenceLevel
Levels of confidence.
DocumentType
Document types
EventRoleType
Standard event roles.
EventType
Standard event types.
FactQualifier
Fact qualifiers.
FactType
Standard fact types.
GedcomxError
An error returned by the library.
GenderType
Type of gender.
GroupRoleType
Group role types.
IdentifierType
Standard identifier types. Custom identifier types should not have a value of “$” since this is reserved for identifiers without a type in JSON.
NamePartQualifier
Name part qualifiers.
NamePartType
Standard name part types.
NameType
Standard name types.
RelationshipType
Standard relationship types.
ResourceType
Standard resource types.
SourceReferenceQualifier
Source reference qualifiers.
TextType
The styling or layout of type of text.

Type Aliases§

Result