#citeworks #file-format #citation #author #serde #url #cff

citeworks-cff

Serde types for serialising and deserialising CFF (Citation File Format)

2 releases

0.1.1 Aug 31, 2022
0.1.0 Aug 13, 2022

#9 in #citation


Used in citeworks-cli

Apache-2.0

37KB
634 lines

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")
);

Dependencies

~6MB
~98K SLoC