pub struct StyleRegistry {
pub version: String,
pub styles: Vec<RegistryEntry>,
}Expand description
A registry of citation styles with alias resolution.
Fields§
§version: StringVersion identifier for the registry format.
styles: Vec<RegistryEntry>List of style entries in the registry.
Implementations§
Source§impl StyleRegistry
impl StyleRegistry
Sourcepub fn resolve(&self, name: &str) -> Option<&RegistryEntry>
pub fn resolve(&self, name: &str) -> Option<&RegistryEntry>
Resolve a name or alias to the matching registry entry.
Checks id first, then searches aliases.
Sourcepub fn merge_over(&self, base: &StyleRegistry) -> StyleRegistry
pub fn merge_over(&self, base: &StyleRegistry) -> StyleRegistry
Merge another registry over self (self wins on ID conflict).
Entries from base are included first. If an entry in self
has the same ID as one in base, the entry from self replaces it.
New entries from self are appended.
Sourcepub fn from_slices(names: &[&str], aliases: &[(&str, &str)]) -> StyleRegistry
pub fn from_slices(names: &[&str], aliases: &[(&str, &str)]) -> StyleRegistry
Build a registry from embedded style name and alias slices.
Used to construct the default registry from hardcoded embedded data.
Sourcepub fn load_default() -> StyleRegistry
pub fn load_default() -> StyleRegistry
Load the embedded default registry from the compiled-in YAML data.
§Panics
Panics only if the embedded YAML is malformed (should never happen in a correctly built binary).
Sourcepub fn load_from_file(path: &Path) -> Result<StyleRegistry, Box<dyn Error>>
pub fn load_from_file(path: &Path) -> Result<StyleRegistry, Box<dyn Error>>
Load a registry from a YAML file on disk.
§Errors
Returns an error if the file cannot be read or if the YAML cannot be parsed.
Also returns an error if any entry does not have exactly one of
builtin, path, or url.
Trait Implementations§
Source§impl Clone for StyleRegistry
impl Clone for StyleRegistry
Source§fn clone(&self) -> StyleRegistry
fn clone(&self) -> StyleRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more