Skip to main content

AbcMetadata

Struct AbcMetadata 

Source
pub struct AbcMetadata {
    pub src: String,
    pub tag: String,
    pub data: String,
    pub line: usize,
}
Expand description

A line of metadata, T:Title and the like: music21’s ABCMetadata. Its tag and data are empty until AbcMetadata::pre_parse.

Fields§

§src: String

The text it was read from.

§tag: String

The capital letter, or w, before the colon.

§data: String

What follows the colon, trimmed, a comment taken off.

§line: usize

The line of the text it stands on, counted from one; nought where unknown.

Implementations§

Source§

impl AbcMetadata

Source

pub fn new(src: &str) -> Self

An unread line of src.

Source

pub fn pre_parse(&mut self)

music21’s preParse: the tag and the data split apart.

use music21::abc::step::AbcMetadata;

let mut line = AbcMetadata::new("T:tagData % a comment");
line.pre_parse();
assert_eq!((line.tag.as_str(), line.data.as_str()), ("T", "tagData"));
Source

pub fn meter_parameters(&self) -> Result<Option<(u32, u32, &'static str)>>

music21’s getTimeSignatureParameters: the meter’s numerator, denominator and symbol (normal, common or cut), nothing for M:none.

Source

pub fn meter(&self) -> Result<Option<TimeSignature>>

music21’s getTimeSignatureObject.

Source

pub fn key_parameters(&self) -> Result<(IntegerType, Option<&'static str>)>

music21’s getKeySignatureParameters: the signed count of sharps and the mode, where the key names one.

use music21::abc::step::AbcMetadata;

let mut line = AbcMetadata::new("K:Eb Lydian");
line.pre_parse();
assert_eq!(line.key_parameters()?, (-2, Some("lydian")));
Source

pub fn key(&self) -> Result<StreamElement>

music21’s getKeySignatureObject: a key where there is a mode, a signature otherwise.

Source

pub fn clef(&self) -> Result<Option<(Clef, IntegerType)>>

music21’s getClefObject: the clef a key line names, and how far the notes under it are moved.

Source

pub fn tempo(&self) -> Result<MetronomeMark>

music21’s getMetronomeMarkObject.

Source

pub fn default_quarter_length(&self) -> Result<FloatType>

music21’s getDefaultQuarterLength, for an L: or an M: line.

use music21::abc::step::AbcMetadata;

let mut line = AbcMetadata::new("M:2/4");
line.pre_parse();
assert_eq!(line.default_quarter_length()?, 0.25);

Trait Implementations§

Source§

impl Clone for AbcMetadata

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 AbcMetadata

Source§

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

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

impl Default for AbcMetadata

Source§

fn default() -> Self

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

impl PartialEq for AbcMetadata

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 AbcMetadata

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.