Struct wca::GrammarConverter
source · pub struct GrammarConverter {
pub commands: HashMap<String, Vec<Command>>,
}Expand description
Converts a RawCommand to a GrammarCommand by performing validation and type casting on values.
let grammar = GrammarConverter::former()
.command
(
Command::former()
.hint( "hint" )
.long_hint( "long_hint" )
.phrase( "command" )
.form()
)
.form();
let raw_command = RawCommand
{
name: "command".to_string(),
subjects: vec![],
properties: HashMap::new(),
};
let grammar_command = grammar.to_command( raw_command )?;Fields§
§commands: HashMap<String, Vec<Command>>all available commands
Implementations§
source§impl GrammarConverter
impl GrammarConverter
sourcepub fn to_program(
&self,
raw_program: Program<Namespace<RawCommand>>
) -> Result<Program<Namespace<GrammarCommand>>>
pub fn to_program( &self, raw_program: Program<Namespace<RawCommand>> ) -> Result<Program<Namespace<GrammarCommand>>>
Converts raw program to grammatically correct
Converts all namespaces into it with to_namespace method.
sourcepub fn to_namespace(
&self,
raw_namespace: Namespace<RawCommand>
) -> Result<Namespace<GrammarCommand>>
pub fn to_namespace( &self, raw_namespace: Namespace<RawCommand> ) -> Result<Namespace<GrammarCommand>>
Converts raw namespace to grammatically correct
Converts all commands into it with to_command method.
sourcepub fn to_command(&self, raw_command: RawCommand) -> Result<GrammarCommand>
pub fn to_command(&self, raw_command: RawCommand) -> Result<GrammarCommand>
Converts raw command to grammatically correct
Make sure that this command is described in the grammar and matches it(command itself and all it options too).
Trait Implementations§
source§impl Clone for GrammarConverter
impl Clone for GrammarConverter
source§fn clone(&self) -> GrammarConverter
fn clone(&self) -> GrammarConverter
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl RefUnwindSafe for GrammarConverter
impl Send for GrammarConverter
impl Sync for GrammarConverter
impl Unpin for GrammarConverter
impl UnwindSafe for GrammarConverter
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