pub struct DatePrimitive { /* private fields */ }Expand description
One or more dates and what they say: music21’s DatePrimitive and the
four classes under it, which differ only in the relevances they take and
in how they are written.
use music21::metadata::primitives::{DateKind, DatePrimitive, Relevance};
let span = DatePrimitive::between(["2009/12/31", "2010/1/28"])?;
assert_eq!(span.to_string(), "2009/12/31 to 2010/01/28");
assert_eq!(span.kind(), DateKind::Between);
let prior = DatePrimitive::relative("2009/12/31", Relevance::Prior)?;
assert_eq!(prior.to_string(), "prior to 2009/12/31");Implementations§
Source§impl DatePrimitive
impl DatePrimitive
Sourcepub fn set_relevance(&mut self, relevance: Relevance) -> Result<()>
pub fn set_relevance(&mut self, relevance: Relevance) -> Result<()>
Says something else about the dates it holds.
§Errors
A relevance one of music21’s other date classes keeps: its own
setters refuse any that is not theirs, so DateSingle cannot be
made to say between.
Sourcepub fn single(written: &str, relevance: Relevance) -> Result<Self>
pub fn single(written: &str, relevance: Relevance) -> Result<Self>
One date: music21’s DateSingle.
§Errors
A date that cannot be read, or a relevance DateSingle does not
take.
Sourcepub fn relative(written: &str, relevance: Relevance) -> Result<Self>
pub fn relative(written: &str, relevance: Relevance) -> Result<Self>
A date something happened before or after: music21’s
DateRelative.
§Errors
A date that cannot be read, or a relevance DateRelative does not
take.
Trait Implementations§
Source§impl Clone for DatePrimitive
impl Clone for DatePrimitive
Source§impl Debug for DatePrimitive
impl Debug for DatePrimitive
Source§impl<'de> Deserialize<'de> for DatePrimitive
Available on crate feature serde only.
impl<'de> Deserialize<'de> for DatePrimitive
Available on crate feature
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for DatePrimitive
impl Display for DatePrimitive
impl Eq for DatePrimitive
Source§impl Hash for DatePrimitive
impl Hash for DatePrimitive
Source§impl PartialEq for DatePrimitive
impl PartialEq for DatePrimitive
Source§impl Serialize for DatePrimitive
Available on crate feature serde only.
impl Serialize for DatePrimitive
Available on crate feature
serde only.impl StructuralPartialEq for DatePrimitive
Auto Trait Implementations§
impl Forget for DatePrimitive
impl Freeze for DatePrimitive
impl RefUnwindSafe for DatePrimitive
impl Send for DatePrimitive
impl Sync for DatePrimitive
impl Unpin for DatePrimitive
impl UnsafeUnpin for DatePrimitive
impl UnwindSafe for DatePrimitive
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
Mutably borrows from an owned value. Read more
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> ⓘ
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 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> ⓘ
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