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>
impl<'a> LyricSearcher<'a>
Sourcepub fn new(stream: &'a Stream) -> Self
pub fn new(stream: &'a Stream) -> Self
The lyrics of a stream, nested streams included, read with a space between words.
Sourcepub fn with_word_separator(stream: &'a Stream, word_separator: &str) -> Self
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.
Sourcepub fn index_text(&self) -> &str
pub fn index_text(&self) -> &str
The text searched: each verse’s lyrics, the verses joined with
LINE_BREAK: music21’s indexText.
Sourcepub fn indexed(&self) -> &[IndexedLyric<'a>]
pub fn indexed(&self) -> &[IndexedLyric<'a>]
Every lyric with text and where it sits in Self::index_text:
music21’s indexTuples.
Sourcepub fn search(&self, text: &str) -> Result<Vec<LyricMatch<'a>>>
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>
impl<'a> Clone for LyricSearcher<'a>
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> 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