Crate citeworks_cff

Crate citeworks_cff 

Source
Expand description

Citation File Format serde types and implementations.

This targets CFF 1.2.0 but may not support the entire specification.

The top level API mimics serde_yaml’s:

let cff = citeworks_cff::from_str(r#"
cff-version: 1.2.0
message:
  If you dare use this commercial, closed-source, strangely versioned
  software in your research, please at least cite it as below.
authors:
  - family-names: Vader
    name-suffix: né Skywalker
    given-names: 'Anakin "Darth"'
  - name: anonymous
title: Opaquity
version: opq-1234-XZVF-ACME-RLY
date-released: 2017-02-28
url: http://www.opaquity.com/
contact:
  - name: Dark Side Software
    address: DS-1 Orbital Battle Station, near Scarif
    email: father@imperial-empire.com
    tel: +850 (0)123-45-666
"#).unwrap();

assert_eq!(
    cff
        .authors[0]
        .as_person()
        .and_then(|his| his.family_names.as_deref()),
    Some("Vader")
);

Modules§

identifiers
Types and utilities for identifiers e.g. DOIs.
names
Types and utilities for names e.g. of authors.
references
Types and utilities for references to this or other works.

Structs§

Cff
The top-level CFF document.
Date
A date.

Enums§

License
License field value.
WorkType
Types of works recognised by CFF.

Functions§

from_reader
Deserialize CFF from an IO stream of YAML.
from_slice
Deserialize CFF from bytes of YAML text.
from_str
Deserialize CFF from a string of YAML text.
to_string
Serialize the given CFF as a String of YAML.
to_vec
Serialize the given CFF as a YAML byte vector.
to_writer
Serialize the given CFF as YAML into the IO stream.

Type Aliases§

Result
Alias for a Result with the error type serde_yaml::Error.