Skip to main content

CitationSpec

Struct CitationSpec 

Source
pub struct CitationSpec {
Show 19 fields pub options: Option<CitationOptions>, pub template_ref: Option<TemplateReference>, pub template: Option<Vec<TemplateComponent>>, pub locales: Option<Vec<LocalizedTemplateSpec>>, pub type_variants: Option<IndexMap<TypeSelector, TemplateVariant>>, pub wrap: Option<WrapConfig>, pub prefix: Option<String>, pub suffix: Option<String>, pub delimiter: Option<String>, pub multi_cite_delimiter: Option<String>, pub collapse: Option<CitationCollapse>, pub sort: Option<GroupSortEntry>, pub integral: Option<Box<CitationSpec>>, pub non_integral: Option<Box<CitationSpec>>, pub subsequent: Option<Box<CitationSpec>>, pub ibid: Option<Box<CitationSpec>>, pub note_start_text_case: Option<NoteStartTextCase>, pub custom: Option<HashMap<String, Value>>, pub unknown_fields: BTreeMap<String, Value>,
}
Expand description

Citation specification.

Fields§

§options: Option<CitationOptions>

Citation-specific option overrides merged over the style config.

§template_ref: Option<TemplateReference>

Reference to an embedded template preset or external template.

If both template-ref and template are present, template takes precedence.

§template: Option<Vec<TemplateComponent>>

Default template when no localized override is selected.

§locales: Option<Vec<LocalizedTemplateSpec>>

Locale-specific template overrides checked before the default template.

§type_variants: Option<IndexMap<TypeSelector, TemplateVariant>>

Type-specific template overrides for citations. When present, replaces the default citation template for references of the specified types. Type-variant lookup happens after mode (integral/non-integral) resolution. If both the main spec and the active mode sub-spec have a type-variants entry for the same type, the mode-specific one wins.

§wrap: Option<WrapConfig>

Wrap the entire citation in punctuation. Preferred over prefix/suffix.

§prefix: Option<String>

Prefix for the citation (use only when wrap doesn’t suffice, e.g., “ (“ or “[Ref “).

§suffix: Option<String>

Suffix for the citation (use only when wrap doesn’t suffice).

§delimiter: Option<String>

Delimiter between components within a single citation item (e.g., “, “ or “ “). Defaults to “, “.

§multi_cite_delimiter: Option<String>

Delimiter between multiple citation items (e.g., “; “). Defaults to “; “.

§collapse: Option<CitationCollapse>

Optional collapse behavior for adjacent multi-item citations.

§sort: Option<GroupSortEntry>

Optional citation sorting specification.

§integral: Option<Box<CitationSpec>>

Configuration for integral (narrative) citations (e.g., “Smith (2020)”). Overrides fields from the main citation spec when mode is Integral.

§non_integral: Option<Box<CitationSpec>>

Configuration for non-integral (parenthetical) citations (e.g., “(Smith, 2020)”). Overrides fields from the main citation spec when mode is NonIntegral.

§subsequent: Option<Box<CitationSpec>>

Configuration for subsequent citations. Overrides fields from the main citation spec when position is Subsequent. Useful for short-form citations in note-based styles or author-date styles that show abbreviated citations after the first mention.

§ibid: Option<Box<CitationSpec>>

Configuration for ibid citations (ibid or ibid with locator). Overrides fields from the main citation spec when position is Ibid or IbidWithLocator. If present, takes precedence over subsequent for these positions. Allows compact rendering like “ibid.” or “ibid., p. 45”.

§note_start_text_case: Option<NoteStartTextCase>

Optional text-case transform for standalone note-start citation output.

This is a style-owned rendering dimension layered on top of the existing repeated-note state, not a new citation Position.

§custom: Option<HashMap<String, Value>>

Custom user-defined fields for extensions.

§unknown_fields: BTreeMap<String, Value>

Forward-compat: captures unknown keys when an older engine reads a style produced by a newer schema. Empty by default; treated as a SoftDegrade signal. See docs/specs/FORWARD_COMPATIBILITY.md.

Implementations§

Source§

impl CitationSpec

Source

pub fn resolve_template(&self) -> Option<Vec<TemplateComponent>>

Resolve the effective template for this citation.

Returns the explicit template if present, otherwise resolves template-ref. Returns None if neither is specified.

Source

pub fn resolve_template_for_language( &self, language: Option<&str>, ) -> Option<Vec<TemplateComponent>>

Resolve the template for a language by checking localized overrides, then the localized default, then the base template or preset.

Source

pub fn resolve_template_for_type( &self, ref_type: &str, language: Option<&str>, ) -> Option<Vec<TemplateComponent>>

Resolve the template for a given reference type and language.

First checks type_variants for an entry matching ref_type. Falls back to resolve_template_for_language if no type-specific template is found.

Source

pub fn resolve_for_mode(&self, mode: &CitationMode) -> Cow<'_, CitationSpec>

Resolve the effective spec for a given citation mode.

If a mode-specific spec exists (e.g., integral), it merges with and overrides the base spec.

Source

pub fn resolve_for_position( &self, position: Option<&Position>, ) -> Cow<'_, CitationSpec>

Resolve the effective spec for a given citation position.

If a position-specific spec exists (e.g., ibid for Ibid position), it merges with and overrides the base spec. Position resolution should be applied before mode resolution to allow position-specific modes.

Priority: ibid > subsequent > base

Trait Implementations§

Source§

impl Clone for CitationSpec

Source§

fn clone(&self) -> CitationSpec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CitationSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for CitationSpec

Source§

fn default() -> CitationSpec

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CitationSpec

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<CitationSpec, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for CitationSpec

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,