Skip to main content

Style

Struct Style 

Source
pub struct Style {
    pub version: SchemaVersion,
    pub info: StyleInfo,
    pub templates: Option<HashMap<String, Vec<TemplateComponent>>>,
    pub options: Option<Config>,
    pub citation: Option<CitationSpec>,
    pub bibliography: Option<BibliographySpec>,
    pub custom: Option<HashMap<String, Value>>,
    pub extends: Option<StyleReference>,
    pub extends_pin: Option<String>,
    pub raw_yaml: Option<Value>,
    pub unknown_fields: BTreeMap<String, Value>,
}
Expand description

The new Citum Style model.

This is the target schema for Citum, featuring declarative options and simple template components instead of procedural conditionals.

Fields§

§version: SchemaVersion

Style schema version.

§info: StyleInfo

Style metadata.

§templates: Option<HashMap<String, Vec<TemplateComponent>>>

Named reusable templates.

§options: Option<Config>

Global style options.

§citation: Option<CitationSpec>

Citation specification.

§bibliography: Option<BibliographySpec>

Bibliography specification.

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

Custom user-defined fields for extensions.

§extends: Option<StyleReference>

Extends a base style, with optional local overrides.

When present, the base StyleReference is resolved and the local overrides are merged before any further processing. Explicit options, citation, and bibliography keys at the same document level take precedence over the resolved base.

§extends_pin: Option<String>

Optional content-addressed integrity pin for the parent style referenced by extends.

When present, the resolver verifies that the SHA-256 of the fetched parent matches this CIDv1 string before merging. Mismatches abort resolution with ResolutionError::IntegrityFailure. Absent means “no integrity check” — appropriate for file:// parents under user control or trusted local registries.

§raw_yaml: Option<Value>

Raw YAML captured when the style was loaded via Style::from_yaml_str or Style::from_yaml_bytes. Used during style resolution for null-aware overlay merging (e.g., ibid: ~ correctly clears an inherited preset value). Absent in programmatically-constructed styles.

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

Source

pub fn from_yaml_str(s: &str) -> Result<Style, Error>

Parse a Citum style from a YAML string, preserving raw YAML for null-aware overlay merging during base resolution.

Preferred over serde_yaml::from_str when the style extends a base, so that ibid: ~ and similar null overrides correctly clear inherited values.

§Errors

Returns a serde error if YAML parsing or deserialization fails.

Source

pub fn from_yaml_bytes(bytes: &[u8]) -> Result<Style, Error>

Parse a Citum style from YAML bytes, preserving raw YAML for null-aware overlay merging during preset resolution.

§Errors

Returns a serde error if YAML parsing or deserialization fails.

Source§

impl Style

Source

pub fn into_resolved(self) -> Style

Resolve this style into its final effective form by applying base inheritance.

If the extends field is present, the base StyleBase is loaded and any explicit options, citation, or bibliography keys in the current style document are merged on top (taking ultimate precedence).

Styles without a base still resolve Template V3 variants and scoped options, but do not merge any inherited style data.

§Panics

Panics when style resolution fails. Use Style::try_into_resolved to handle profile-contract and inheritance errors explicitly.

Source

pub fn try_into_resolved(self) -> Result<Style, ResolutionError>

Resolve this style into its final effective form, returning validation errors.

Unlike Style::into_resolved, this preserves resolution failures as structured ResolutionError values.

§Errors

Returns an error when profile wrappers try to override template-bearing structure, when profile capability validation fails, or when inheritance loops are detected.

Source

pub fn try_into_resolved_with( self, resolver: Option<&(dyn StyleResolver<Style = Style, Locale = Locale> + 'static)>, ) -> Result<Style, ResolutionError>

Resolve this style into its final effective form using an optional style resolver.

The resolver is used for URI, registry, and remote extends references that cannot be satisfied by embedded bases alone.

§Errors

Returns an error when style inheritance or Template V3 variant resolution fails.

Source

pub fn into_resolved_recursive(self, visited: &mut HashSet<String>) -> Style

Internal recursive resolver with loop protection.

§Panics

Panics when style resolution fails. Use Style::try_into_resolved_recursive to preserve errors.

Source

pub fn try_into_resolved_recursive( self, visited: &mut HashSet<String>, ) -> Result<Style, ResolutionError>

Internal recursive resolver with loop protection.

§Errors

Returns an error when profile wrappers violate the config-only contract, when profile capability validation fails, or when inheritance loops are detected.

Source

pub fn try_into_resolved_recursive_with( self, resolver: Option<&(dyn StyleResolver<Style = Style, Locale = Locale> + 'static)>, visited: &mut HashSet<String>, ) -> Result<Style, ResolutionError>

Internal recursive resolver with loop protection and optional external resolver.

§Errors

Returns an error when style inheritance or Template V3 variant resolution fails.

Source§

impl Style

Source

pub fn validate_resource_limits(&self) -> Result<(), String>

Validate hard resource limits for style templates.

§Errors

Returns an error when authored template structure exceeds the maximum depth or component count accepted by the engine.

Source

pub fn validate(&self) -> Vec<SchemaWarning>

Validate the style and return any non-fatal warnings.

This method checks for issues that are syntactically valid but semantically suspect, such as unrecognized reference type names in TypeSelector values.

Warnings do not prevent rendering; they are informational only.

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Style

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 Style

Source§

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

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

impl Default for Style

Source§

fn default() -> Style

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

impl<'de> Deserialize<'de> for Style

Source§

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

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

impl Serialize for Style

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§

§

impl Freeze for Style

§

impl RefUnwindSafe for Style

§

impl Send for Style

§

impl Sync for Style

§

impl Unpin for Style

§

impl UnsafeUnpin for Style

§

impl UnwindSafe for Style

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,