[−][src]Struct hexavalent::hook::HookHandle
A handle to a hook registered with HexChat.
Cannot be constructed in user code, but is returned from hook registration functions such as
PluginHandle::hook_command
.
Can be passed to PluginHandle::unhook
to unregister the hook.
HexChat automatically unhooks any remaining hooks after your plugin finishes unloading, so this type is only useful if you need to unhook a hook while your plugin is running.
Examples
use std::cell::Cell; use hexavalent::{Plugin, PluginHandle}; use hexavalent::hook::{Eat, HookHandle, Priority}; #[derive(Default)] struct MyPlugin { cmd_handle: Cell<Option<HookHandle>>, } impl Plugin for MyPlugin { fn init(&self, ph: PluginHandle<'_, Self>) { let hook = ph.hook_command( "theCommand\0", "Usage: THECOMMAND, can be disabled\0", Priority::Normal, |plugin, ph, words| { ph.print("Yep, it still works.\0"); Eat::All } ); self.cmd_handle.set(Some(hook)); ph.hook_command( "disableTheCommand\0", "Usage: DISABLETHECOMMAND, disables /theCommand\0", Priority::Normal, |plugin, ph, words| { match plugin.cmd_handle.take() { Some(hook) => { ph.unhook(hook); ph.print("Disabled the command!\0"); } None => { ph.print("Command already disabled!\0"); } } Eat::All } ); } }
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for HookHandle
[src]
impl !Send for HookHandle
[src]
impl !Sync for HookHandle
[src]
impl Unpin for HookHandle
[src]
impl UnwindSafe for HookHandle
[src]
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,
pub 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, 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.
pub 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>,