Skip to main content

LyricSearcher

Struct LyricSearcher 

Source
pub struct LyricSearcher<'a> { /* private fields */ }
Expand description

Finds text in a stream’s lyrics: music21’s LyricSearcher. Each verse’s lyrics are read as one text, syllables of a word run together and words apart, and the verses one after another with LINE_BREAK between them; a search finds each place the text comes and the lyrics and notes there.

use music21_rs::search::LyricSearcher;
use music21_rs::tinynotation::from_tiny_notation;

let line = from_tiny_notation("4/4 c4_Et d_in f_terra a_pax")?;
let searcher = LyricSearcher::new(&line);
assert_eq!(searcher.index_text(), "Et in terra pax");
let found = searcher.search("in ter")?;
assert_eq!(found[0].elements().len(), 2);

Implementations§

Source§

impl<'a> LyricSearcher<'a>

Source

pub fn new(stream: &'a Stream) -> Self

The lyrics of a stream, nested streams included, read with a space between words.

Source

pub fn with_word_separator(stream: &'a Stream, word_separator: &str) -> Self

The lyrics of a stream read with this between words: music21’s LyricSearcher(s, wordSeparator=...), indexed as its index does.

Source

pub fn index_text(&self) -> &str

The text searched: each verse’s lyrics, the verses joined with LINE_BREAK: music21’s indexText.

Source

pub fn indexed(&self) -> &[IndexedLyric<'a>]

Every lyric with text and where it sits in Self::index_text: music21’s indexTuples.

Source

pub fn search(&self, text: &str) -> Result<Vec<LyricMatch<'a>>>

Each place text comes in the lyrics, left to right, none overlapping the one before: music21’s search of a plain string.

§Errors

A match that touches no lyric, which music21 refuses: one that lies wholly in the space between words or verses.

Trait Implementations§

Source§

impl<'a> Clone for LyricSearcher<'a>

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<'a> Debug for LyricSearcher<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for LyricSearcher<'a>

§

impl<'a> RefUnwindSafe for LyricSearcher<'a>

§

impl<'a> Send for LyricSearcher<'a>

§

impl<'a> Sync for LyricSearcher<'a>

§

impl<'a> Unpin for LyricSearcher<'a>

§

impl<'a> UnsafeUnpin for LyricSearcher<'a>

§

impl<'a> UnwindSafe for LyricSearcher<'a>

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.