[][src]Struct weechat::hooks::Command

pub struct Command { /* fields omitted */ }

Hook for a weechat command, the command is removed when the object is dropped.

Implementations

impl Command[src]

pub fn new(
    command_settings: CommandSettings,
    callback: impl CommandCallback + 'static
) -> Result<Command, ()>
[src]

Create a new Weechat command.

Returns the hook of the command. The command is unhooked if the hook is dropped.

Arguments

  • command_settings - Settings for the new command.

  • callback - The callback that will be called if the command is run.

let settings = CommandSettings::new("irc")
    .description("IRC chat protocol command.")
    .add_argument("server add <server-name> <hostname>[:<port>]")
    .add_argument("server delete|list|listfull <server-name>")
    .add_argument("connect <server-name>")
    .add_argument("disconnect <server-name>")
    .add_argument("reconnect <server-name>")
    .add_argument("help <irc-command> [<irc-subcommand>]")
    .arguments_description(
        "     server: List, add, or remove IRC servers.
    connect: Connect to a IRC server.
 disconnect: Disconnect from one or all IRC servers.
  reconnect: Reconnect to server(s).
       help: Show detailed command help.\n
Use /irc [command] help to find out more.\n",
    )
    .add_completion("server |add|delete|list|listfull")
    .add_completion("connect")
    .add_completion("disconnect")
    .add_completion("reconnect")
    .add_completion("help server|connect|disconnect|reconnect");

let command = Command::new(
    settings,
    |_: &Weechat, buffer: &Buffer, args: Args| {
        buffer.print(&format!("Command called with args {:?}", args));
    }
).expect("Can't create command");

Auto Trait Implementations

impl !RefUnwindSafe for Command

impl !Send for Command

impl !Sync for Command

impl Unpin for Command

impl !UnwindSafe for Command

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.