Skip to main content

OffsetSpan

Struct OffsetSpan 

Source
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: FloatType

Where the span starts: offsetStart.

§end: Option<FloatType>

Where it ends, or nothing for a span of no length at start: offsetEnd.

§include_end_boundary: bool

Whether an element starting exactly where the span ends is taken: includeEndBoundary.

§must_finish_in_span: bool

Whether an element sounding past the end of the span is left out: mustFinishInSpan.

§must_begin_in_span: bool

Whether an element starting before the span is left out: mustBeginInSpan.

§include_elements_that_end_at_start: bool

Whether an element ending exactly where the span starts is taken: includeElementsThatEndAtStart.

Implementations§

Source§

impl OffsetSpan

Source

pub fn at(offset: FloatType) -> Self

One offset, with music21’s defaults: a span of no length, which takes every element sounding across it and every mark standing on it.

Source

pub fn between(start: FloatType, end: FloatType) -> Self

A stretch from one offset to another, with music21’s defaults.

Source§

impl OffsetSpan

Source

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

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 Copy for OffsetSpan

Source§

impl Debug for OffsetSpan

Source§

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

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

impl PartialEq for OffsetSpan

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 StructuralPartialEq for OffsetSpan

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> 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, 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.