pub struct ModifierHook { /* private fields */ }
Expand description
Hook for a modifier, the hook is removed when the object is dropped.
Implementations§
Source§impl ModifierHook
impl ModifierHook
Sourcepub fn new(
modifier_name: &str,
callback: impl ModifierCallback + 'static,
) -> Result<Self, ()>
Available on unsound
only.
pub fn new( modifier_name: &str, callback: impl ModifierCallback + 'static, ) -> Result<Self, ()>
unsound
only.Hook a modifier.
§Arguments
-
modifier_name
- The modifier to hook. -
callback
- A function or a struct that implements ModifierCallback, the callback method of the trait will be called when the modifier is fired.
§Panics
Panics if the method is not called from the main Weechat thread.
§Example
let modifier_hook = ModifierHook::new(
"input_text_display_with_cursor",
|_weechat: &Weechat,
_modifier_name: &str,
data: Option<ModifierData>,
string: Cow<str>| {
if let ModifierData::Buffer(buffer) = data? {
buffer.print("Modifying the input buffer")
}
None
});
Auto Trait Implementations§
impl Freeze for ModifierHook
impl !RefUnwindSafe for ModifierHook
impl !Send for ModifierHook
impl !Sync for ModifierHook
impl Unpin for ModifierHook
impl !UnwindSafe for ModifierHook
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