pub struct Parser { /* private fields */ }Expand description
A parser with its options resolved and its vocabulary tables built once (createParser in
JavaScript, create_parser in Python). Use it to parse many strings with the same options.
It is Send + Sync, and cloning it is cheap (the tables are shared).
use trackparse::{ParseOptions, Parser};
let parser = Parser::new(&ParseOptions::new().known_artists(["Chase & Status"]));
let track = parser.parse("Chase & Status - Blind Faith");
assert_eq!(track.artists.len(), 1);
assert_eq!(track.artists[0].name, "Chase & Status");Implementations§
Source§impl Parser
impl Parser
Sourcepub fn new(options: &ParseOptions) -> Parser
pub fn new(options: &ParseOptions) -> Parser
Resolve options and build the vocabulary tables.
Sourcepub fn parse(&self, input: &str) -> ParsedTrack
pub fn parse(&self, input: &str) -> ParsedTrack
parse with this parser’s options.
Sourcepub fn parse_artists(&self, input: &str) -> Vec<Artist>
pub fn parse_artists(&self, input: &str) -> Vec<Artist>
parse_artists with this parser’s options.
use trackparse::{ParseOptions, Parser, SplitAnd};
let parser = Parser::new(&ParseOptions::new().split_and(SplitAnd::Always));
assert_eq!(parser.parse_artists("Above and Beyond").len(), 2);Trait Implementations§
Auto Trait Implementations§
impl Forget for Parser
impl Freeze for Parser
impl Move for Parser
impl RefUnwindSafe for Parser
impl Send for Parser
impl Sync for Parser
impl Unpin for Parser
impl UnsafeUnpin for Parser
impl UnwindSafe for Parser
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
Mutably borrows from an owned value. Read more