Skip to main content

Handler

Struct Handler 

Source
pub struct Handler {
    pub version: (u32, u32, u32),
    pub directives: Vec<(String, String)>,
    pub tokens: Vec<Token>,
    pub active: Vec<usize>,
}
Expand description

music21’s ABCHandler: the tokens of a text and what reading them keeps.

Fields§

§version: (u32, u32, u32)

The ABC version read as: (1, 3, 0) and the like.

§directives: Vec<(String, String)>

The %%key value directives read, in order.

§tokens: Vec<Token>

The tokens, in the order of the text.

§active: Vec<usize>

The spanners still open after Handler::process, by where they stand among those it handed back.

Implementations§

Source§

impl Handler

Source

pub fn new(version: (u32, u32, u32)) -> Self

A handler of no tokens, reading as ABC version.

Source

pub fn accidental_propagation(&self) -> &str

music21’s _accidentalPropagation: not, pitch or octave.

Source

pub fn read_version(&mut self, text: &str)

music21’s parseHeaderForVersionInformation: the version named by %abc-2.1 in text.

Source

pub fn bar_tokens(text: &str) -> Vec<Bar>

music21’s barlineTokenFilter: a bar written as two in one, each unread.

Source

pub fn tokenize(&mut self, source: &str) -> Result<()>

music21’s tokenize: the tokens of source added to the handler’s, what goes wrong placed at its line and column.

Source

pub fn process(&mut self) -> Result<Vec<Spanning>>

music21’s tokenProcess: each token pre-parsed, told what is in force where it stands, and then parsed. Hands back the spanners the tokens started; those left open are in active.

Source

pub fn defines_reference_numbers(&self) -> bool

music21’s definesReferenceNumbers: more than one X:.

Source

pub fn reference_number(&self) -> Option<&str>

music21’s getReferenceNumber: the first X: line’s data.

Source

pub fn title(&self) -> Option<&str>

music21’s getTitle: the first T: line’s data.

Source

pub fn split_by_reference_number( &self, ) -> Result<Vec<(Option<IntegerType>, Vec<usize>)>>

music21’s splitByReferenceNumber: each tune’s tokens by index, the tokens before the first X: in front of each, keyed by number in the order the numbers first stand. A number met again takes the later tune. With no X: at all, the one tune has no number.

Source

pub fn defines_measures(&self) -> bool

music21’s definesMeasures: two plain barlines or more.

Source

pub fn has_notes(&self) -> bool

music21’s hasNotes.

Source

pub fn split_by_voice(&self) -> Vec<Range<usize>>

music21’s splitByVoice: the header, and the tokens of each voice whose V: line starts with a digit; all the tokens where there are fewer than two voices.

Source

pub fn bar_indices(&self) -> Vec<usize>

music21’s tokensToBarIndices: where each bar stands, and each line of metadata a note follows.

Source

pub fn split_by_measure(&self) -> Vec<MeasureSplit>

music21’s splitByMeasure: the tokens of each measure and the bars either side, a repeat’s end kept for the measure before it and a repeat’s start for the one after.

Trait Implementations§

Source§

impl Clone for Handler

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 Debug for Handler

Source§

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

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

impl Default for Handler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.