pub struct OffsetSpan {
pub start: FloatType,
pub end: Option<FloatType>,
pub include_end_boundary: bool,
pub must_finish_in_span: bool,
pub must_begin_in_span: bool,
pub include_elements_that_end_at_start: bool,
}Expand description
A span of offsets to search, and which elements on its edges the search
takes: music21’s getElementsByOffset and the keywords it reads.
Self::at searches one offset and Self::between a stretch. The
four flags start as music21’s own defaults, so a span built by either
answers what music21 answers with no keywords given.
Fields§
§start: FloatTypeWhere the span starts: offsetStart.
end: Option<FloatType>Where it ends, or nothing for a span of no length at start:
offsetEnd.
include_end_boundary: boolWhether an element starting exactly where the span ends is taken:
includeEndBoundary.
must_finish_in_span: boolWhether an element sounding past the end of the span is left out:
mustFinishInSpan.
must_begin_in_span: boolWhether an element starting before the span is left out:
mustBeginInSpan.
include_elements_that_end_at_start: boolWhether an element ending exactly where the span starts is taken:
includeElementsThatEndAtStart.
Implementations§
Source§impl OffsetSpan
impl OffsetSpan
Source§impl OffsetSpan
impl OffsetSpan
Sourcepub fn takes_at(&self, offset: FloatType, quarter_length: FloatType) -> bool
pub fn takes_at(&self, offset: FloatType, quarter_length: FloatType) -> bool
Whether something standing at offset and lasting quarter_length
is in the span: music21’s isElementOffsetInRange.
The decision turns on nothing else, which is why a caller holding its own elements – the Python package holds music21’s objects – can ask this of each rather than keep a second copy of the rules.
use music21_rs::stream::OffsetSpan;
// A half note at nought does not begin in a span of no length at
// 1, which is what music21's `mustBeginInSpan` asks by default.
let at_one = OffsetSpan::at(1.0);
assert!(!at_one.takes_at(0.0, 2.0));
assert!(at_one.takes_at(1.0, 1.0));
let mut sounding = OffsetSpan::at(1.0);
sounding.must_begin_in_span = false;
assert!(sounding.takes_at(0.0, 2.0));Trait Implementations§
Source§impl Clone for OffsetSpan
impl Clone for OffsetSpan
impl Copy for OffsetSpan
Source§impl Debug for OffsetSpan
impl Debug for OffsetSpan
Source§impl PartialEq for OffsetSpan
impl PartialEq for OffsetSpan
impl StructuralPartialEq for OffsetSpan
Auto Trait Implementations§
impl Freeze for OffsetSpan
impl RefUnwindSafe for OffsetSpan
impl Send for OffsetSpan
impl Sync for OffsetSpan
impl Unpin for OffsetSpan
impl UnsafeUnpin for OffsetSpan
impl UnwindSafe for OffsetSpan
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,
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