#[non_exhaustive]pub enum Attribution {
Both {
author: Author,
opus: Opus,
},
AuthorOnly(Author),
OpusOnly(Opus),
}Expand description
The bibliographic information a Cutter number is generated from.
Cutter numbers are normally derived from the author’s name, but works
without a (usable) author are cuttered by title instead, and works with
both can carry a title-derived work mark. Attribution captures which of
these inputs are available for an entry.
Prefer Attribution::from_parts to construct one from optional inputs.
The type is #[non_exhaustive] so the crate can add input shapes in a
future release without a breaking change; downstream matches on it
therefore need a wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Both
Both an author and a work are known.
AuthorOnly(Author)
Only the author is known.
OpusOnly(Opus)
Only the work is known; the Cutter number is derived from its title.
Implementations§
Source§impl Attribution
impl Attribution
Sourcepub fn from_parts(
forename: Option<&str>,
surname: Option<&str>,
title: Option<&str>,
) -> Option<Self>
pub fn from_parts( forename: Option<&str>, surname: Option<&str>, title: Option<&str>, ) -> Option<Self>
Builds an Attribution from optional name and title parts, treating
blank (empty or whitespace-only) strings as absent.
This is the shared front door for user-facing inputs (CLI arguments,
plugin argument maps, FFI bindings): each part is trimmed, blank
parts are dropped, and None is returned when nothing usable
remains.
§Examples
assert!(matches!(
Attribution::from_parts(Some("Charles"), Some("Dickens"), None),
Some(Attribution::AuthorOnly(_))
));
assert!(matches!(
Attribution::from_parts(None, Some(" "), Some("Dune")),
Some(Attribution::OpusOnly(_))
));
assert!(Attribution::from_parts(None, Some(" "), None).is_none());Sourcepub fn with_article_language(self, language: Option<Language>) -> Self
pub fn with_article_language(self, language: Option<Language>) -> Self
Sets the language whose initial article the entry’s title is filed
without, as Opus::with_article_language does; None files the
title as written. It applies to the title of Both and OpusOnly, and
does nothing for AuthorOnly. Author names are never stripped: an
article in a name is part of the heading (LC G 100 §10).
Frontends call it after from_parts.
§Examples
use csan_core::{Attribution, Language};
let entry = Attribution::from_parts(None, Some("Dickens"), Some("A Christmas Carol"))
.map(|entry| entry.with_article_language(Some(Language::English)));
assert!(matches!(
entry,
Some(Attribution::Both { ref opus, .. }) if opus.filing_title() == "Christmas Carol"
));