Skip to main content

Contributor

Struct Contributor 

Source
pub struct Contributor { /* private fields */ }
Expand description

Somebody who had a hand in a work: music21’s metadata.Contributor. A composer, a lyricist, an arranger, or anybody else, under one or more names.

use music21::metadata::primitives::{Contributor, Text};

let composer = Contributor::new("composer", [Text::new("Beethoven, Ludwig van")]);
assert_eq!(composer.role(), Some("composer"));
assert_eq!(composer.to_string(), "composer:Beethoven, Ludwig van");

Implementations§

Source§

impl Contributor

Source

pub fn role_of_abbreviation(abbreviation: &str) -> Result<&'static str>

The role an abbreviation stands for, read without regard to case: music21’s abbreviationToRole.

§Errors

An abbreviation no role is written with.

Source

pub fn abbreviation_of_role(role: &str) -> Result<&'static str>

The abbreviation a role is written with, read without regard to case: music21’s roleToAbbreviation.

§Errors

A role no abbreviation is written for.

Source

pub fn new<I, T>(role: impl Into<String>, names: I) -> Self
where I: IntoIterator<Item = T>, T: Into<Text>,

Somebody in a role, under these names. An abbreviation is read as the role it stands for.

Source

pub fn unnamed() -> Self

Somebody in no role at all, which is what music21 starts a contributor out as.

Source

pub fn role(&self) -> Option<&str>

What they did, where it is known.

Source

pub fn names(&self) -> &[Text]

Every name they go by, the first being the one music21 answers for name.

Source

pub fn name(&self) -> Option<&Text>

The name they go by.

Source

pub fn birth(&self) -> Option<&DatePrimitive>

When they were born, where it is known.

Source

pub fn death(&self) -> Option<&DatePrimitive>

When they died, where it is known.

Source

pub fn set_role(&mut self, role: Option<String>)

Says what they did. An abbreviation is read as the role it stands for, as music21’s own setter reads one, so a contributor given com is a composer.

Source

pub fn set_name(&mut self, name: Text)

Gives them one name, in place of any they had: music21’s name setter, which replaces the whole list.

Source

pub fn set_names(&mut self, names: Vec<Text>)

Gives them every name they go by.

Source

pub fn set_birth(&mut self, birth: Option<DatePrimitive>)

Says when they were born.

Source

pub fn set_death(&mut self, death: Option<DatePrimitive>)

Says when they died.

Trait Implementations§

Source§

impl Clone for Contributor

Source§

fn clone(&self) -> Self

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 Contributor

Source§

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

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

impl Default for Contributor

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Contributor

Available on crate feature serde only.
Source§

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

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

impl Display for Contributor

Written as music21’s _reprInternal writes one: the role, a colon, and every name they go by.

Source§

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

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

impl Eq for Contributor

Source§

impl Hash for Contributor

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Contributor

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Contributor

Available on crate feature serde only.
Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Contributor

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.