Skip to main content

citum_schema_data/
lib.rs

1/*
2SPDX-License-Identifier: MIT OR Apache-2.0
3SPDX-FileCopyrightText: © 2023-2026 Bruce D'Arcus
4*/
5
6//! Data input models for Citum references, citations, and bibliographies.
7
8use indexmap::IndexMap;
9#[cfg(feature = "schema")]
10use schemars::JsonSchema;
11use serde::{Deserialize, Serialize};
12#[cfg(feature = "bindings")]
13use specta::Type;
14use std::collections::HashMap;
15
16/// Document-level abbreviation map type.
17pub mod abbreviation;
18/// Declarative macros.
19#[macro_use]
20pub mod macros;
21/// Citation input model.
22#[allow(missing_docs, reason = "internal derives")]
23pub mod citation;
24/// Bibliographic reference data types.
25#[allow(missing_docs, reason = "internal derives")]
26pub mod reference;
27
28pub use abbreviation::AbbreviationMap;
29pub use citation::{
30    Citation, CitationItem, CitationMode, Citations, IntegralNameState, LocatorType, Position,
31};
32
33/// A collection of bibliographic references with optional metadata.
34#[derive(Debug, Default, Deserialize, Serialize, Clone)]
35#[cfg_attr(feature = "schema", derive(JsonSchema))]
36#[cfg_attr(feature = "bindings", derive(Type))]
37#[serde(rename_all = "kebab-case")]
38pub struct InputBibliography {
39    /// Bibliography metadata.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub info: Option<InputBibliographyInfo>,
42    /// The list of references.
43    pub references: Vec<reference::InputReference>,
44    /// Optional compound entry sets keyed by set id.
45    ///
46    /// Each set id maps to an ordered list of reference ids that should be treated
47    /// as one compound numeric group when `compound-numeric` is enabled by style.
48    #[serde(skip_serializing_if = "Option::is_none")]
49    #[cfg_attr(
50        feature = "schema",
51        schemars(with = "Option<std::collections::BTreeMap<String, Vec<String>>>")
52    )]
53    pub sets: Option<IndexMap<String, Vec<String>>>,
54    /// Custom user-defined fields for extensions.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    #[cfg_attr(feature = "bindings", specta(type = Option<serde_json::Value>))]
57    pub custom: Option<HashMap<String, serde_json::Value>>,
58}
59
60/// Metadata for an input bibliography.
61#[derive(Debug, Default, Deserialize, Serialize, Clone)]
62#[cfg_attr(feature = "schema", derive(JsonSchema))]
63#[cfg_attr(feature = "bindings", derive(Type))]
64#[serde(rename_all = "kebab-case")]
65pub struct InputBibliographyInfo {
66    /// Human-readable title for the bibliography dataset.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub title: Option<String>,
69    /// Creator or maintainer of the bibliography dataset.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub author: Option<String>,
72}