pub struct ChordParser { /* private fields */ }Expand description
The chord parser used for parsing chord signatures into abstract representations defined in chord module
Implementations§
Source§impl ChordParser
impl ChordParser
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new instance of ChordParser.
Use ChordParser::parse(&str) to execute parsing on an input.
Sourcepub fn from_str(s: &str) -> ChordParseResult
pub fn from_str(s: &str) -> ChordParseResult
Parse a chord signature directly from the input.
Shorter than having to create an instance via new function.
§Examples
use chord_parser::*;
let result = ChordParser::from_str("C#7b9"); // Parse directly from the input
match result {
ChordParseResult::Success(chord) => (),
ChordParseResult::Failure(error_kind) => (),
}Sourcepub fn parse(&mut self, s: &str) -> ChordParseResult
pub fn parse(&mut self, s: &str) -> ChordParseResult
Parse a chord signature from a string slice.
§Examples
use chord_parser::*;
let mut parser = ChordParser::new();
let result = parser.parse("C#7b9"); // Parse from the input
match result {
ChordParseResult::Success(chord) => (),
ChordParseResult::Failure(error_kind) => (),
}Sourcepub fn try_parse_interval(&mut self, s: &str) -> Option<AlteredInterval>
pub fn try_parse_interval(&mut self, s: &str) -> Option<AlteredInterval>
Tries to parse the interval from a string slice.
§Examples
use chord_parser::*;
let mut parser = ChordParser::new();
let result = parser.try_parse_interval("13");
match result {
Some(interval) => println!("Interval is: {:?}", interval),
None => panic!("Expected success!"),
}Sourcepub fn try_parse_note_alter(
&mut self,
s: &str,
require_accidental: bool,
) -> Option<ChordNoteAlter>
pub fn try_parse_note_alter( &mut self, s: &str, require_accidental: bool, ) -> Option<ChordNoteAlter>
Tries to parse the note alteration from a string slice.
§Examples
use chord_parser::*;
let mut parser = ChordParser::new();
let result = parser.try_parse_note_alter("b13", true);
match result {
Some(alter) => println!("Alteration is: {:?}", alter),
None => panic!("Forgot an accidental?"),
}Auto Trait Implementations§
impl Freeze for ChordParser
impl RefUnwindSafe for ChordParser
impl Send for ChordParser
impl Sync for ChordParser
impl Unpin for ChordParser
impl UnsafeUnpin for ChordParser
impl UnwindSafe for ChordParser
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