Skip to main content

Attribution

Enum Attribution 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Both

Both an author and a work are known.

Fields

§author: Author

The author of the work.

§opus: Opus

The work itself, used for the work mark.

§

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

Source

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());
Source

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"
));

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.