pub struct MetadataValue { /* private fields */ }Expand description
One value of a metadata name: its text and, for a contributor or a copyright, the role it was given – and the primitive it is, which says what more is known about it.
The text and the role are a reading of the content, not a second copy of it. Every way of building one of these fills all three together and nothing can write to them afterwards, so they cannot drift apart: a contributor’s text is the first name they go by, and a date’s is the way music21 writes it.
A value built as a plain text is not equal to one built as a contributor or a date of the same text, and that is right: the one knows what it is and the other does not.
Implementations§
Source§impl MetadataValue
impl MetadataValue
Sourcepub fn with_role(text: impl Into<String>, role: impl Into<String>) -> Self
pub fn with_role(text: impl Into<String>, role: impl Into<String>) -> Self
A value with a role, as a contributor or a copyright has.
Sourcepub fn of_text(text: Text) -> Self
pub fn of_text(text: Text) -> Self
A value that is a piece of text saying what language it is in:
music21’s Text, or its Copyright where the text has a role.
Sourcepub fn of_contributor(contributor: Contributor) -> Self
pub fn of_contributor(contributor: Contributor) -> Self
A value that is somebody who had a hand in the work: music21’s
Contributor. Its text is the first name they go by, which is what
music21’s own writers write.
Sourcepub fn of_date(date: DatePrimitive) -> Self
pub fn of_date(date: DatePrimitive) -> Self
A value that is a date: music21’s four date classes. Its text is the way music21 writes that date.
Sourcepub fn content(&self) -> &MetadataContent
pub fn content(&self) -> &MetadataContent
What the value is: a text, a contributor or a date.
Sourcepub fn as_contributor(&self) -> Option<&Contributor>
pub fn as_contributor(&self) -> Option<&Contributor>
The contributor, where the value is one.
Sourcepub fn as_date(&self) -> Option<&DatePrimitive>
pub fn as_date(&self) -> Option<&DatePrimitive>
The date, where the value is one.
Trait Implementations§
Source§impl Clone for MetadataValue
impl Clone for MetadataValue
Source§impl Debug for MetadataValue
impl Debug for MetadataValue
Source§impl<'de> Deserialize<'de> for MetadataValue
Available on crate feature serde only.
impl<'de> Deserialize<'de> for MetadataValue
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MetadataValue
Source§impl PartialEq for MetadataValue
impl PartialEq for MetadataValue
Source§impl Serialize for MetadataValue
Available on crate feature serde only.
impl Serialize for MetadataValue
serde only.impl StructuralPartialEq for MetadataValue
Auto Trait Implementations§
impl Forget for MetadataValue
impl Freeze for MetadataValue
impl RefUnwindSafe for MetadataValue
impl Send for MetadataValue
impl Sync for MetadataValue
impl Unpin for MetadataValue
impl UnsafeUnpin for MetadataValue
impl UnwindSafe for MetadataValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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