[−][src]Struct muoxi_staging::prelude::CmdSet
Defines a common collection of commands
The current set up for this logic is that CmdSet is a vector of mutable references to trait objects meaning that all commands and their nature must be defined within the Command trait, defining other data associated with the struct of the Command is futile as the compiler will ambiguous to the actual object the trait is attached too. For example:
Example
struct CmdLook impl CmdLook{ fn method(){ println!("Hello from object specific method"); } } impl Command for CmdLoop{ fn name() -> str{ "look" } ... } let cmdlook = CmdLook{other: 1}; let cmdset = cmdset![cmdlook]; let cmd = cmdset.get("look").unwrap(); cmd.name(); //valid because this method is defined in trait cmd.method() // invalid! Method returns object specific method which is invisible.
The main take away from this, is that Commands should run and be defined all within the Trait, creating a unit struct is just to give the Command a name.
Fields
cmds: Vec<Box<dyn Command + Send>>
holds a list of valid commands in set
Methods
impl CmdSet
[src]
pub fn new(cmds: Vec<Box<dyn Command + Send>>) -> Self
[src]
create a new command set based on appropriate structs that implement Command Trait
pub fn get(&mut self, cmd_string: String) -> Option<&mut (dyn Command + Send)>
[src]
check to see if command exists within CmdSet and returns the dyn Command that it matches with this is still fucking confusing
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for CmdSet
impl Send for CmdSet
impl Sync for CmdSet
impl Unpin for CmdSet
impl !UnwindSafe for CmdSet
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoSql for T
fn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>,
Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>,
&'a Self: AsExpression<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,