pub struct Variant { /* private fields */ }Expand description
Another reading of a passage: music21’s Variant.
use music21_rs::variant::{LengthType, Variant};
use music21_rs::{Duration, Note};
let mut variant = Variant::named("ossia");
variant.contents_mut().push(Note::from_name("D4")?.with_duration(Duration::half()));
assert_eq!(variant.groups(), ["ossia"]);
assert_eq!(variant.replacement_quarter_length(), 2.0);
variant.set_replacement_quarter_length(Some(4.0));
assert_eq!(variant.length_type(), LengthType::Deletion);Implementations§
Source§impl Variant
impl Variant
Sourcepub fn named(name: impl Into<String>) -> Self
pub fn named(name: impl Into<String>) -> Self
A variant holding nothing, in the one group name: music21’s
Variant(name=...).
Sourcepub fn from_stream(contents: Stream) -> Self
pub fn from_stream(contents: Stream) -> Self
A variant holding a stream’s elements where they stand in it.
Sourcepub fn contents_mut(&mut self) -> &mut Stream
pub fn contents_mut(&mut self) -> &mut Stream
The same, to change.
Sourcepub fn groups(&self) -> &[String]
pub fn groups(&self) -> &[String]
The names of the readings the variant belongs to: music21’s
groups.
Sourcepub fn groups_mut(&mut self) -> &mut Vec<String>
pub fn groups_mut(&mut self) -> &mut Vec<String>
The same, to change.
Sourcepub fn replacement_quarter_length(&self) -> FloatType
pub fn replacement_quarter_length(&self) -> FloatType
How much of the stream holding it the variant stands in for: the
length set, or what the reading lasts: music21’s
replacementQuarterLength.
Sourcepub fn set_replacement_quarter_length(&mut self, length: Option<FloatType>)
pub fn set_replacement_quarter_length(&mut self, length: Option<FloatType>)
Sets how much of the stream the variant stands in for, or with
None makes it what the reading lasts.
Sourcepub fn contained_highest_time(&self) -> FloatType
pub fn contained_highest_time(&self) -> FloatType
When the last thing the reading holds ends: music21’s
containedHighestTime.
Sourcepub fn contained_highest_offset(&self) -> FloatType
pub fn contained_highest_offset(&self) -> FloatType
Where the last thing the reading holds starts: music21’s
containedHighestOffset.
Sourcepub fn length_type(&self) -> LengthType
pub fn length_type(&self) -> LengthType
Whether the reading is as long as what it stands in for, longer or
shorter: music21’s lengthType.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Variant
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Variant
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>,
Source§impl From<Variant> for StreamElement
impl From<Variant> for StreamElement
Auto Trait Implementations§
impl Freeze for Variant
impl RefUnwindSafe for Variant
impl Send for Variant
impl Sync for Variant
impl Unpin for Variant
impl UnsafeUnpin for Variant
impl UnwindSafe for Variant
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