[][src]Struct weechat::hooks::SignalHook

pub struct SignalHook { /* fields omitted */ }

Hook for a signal, the hook is removed when the object is dropped.

Implementations

impl SignalHook[src]

pub fn new(
    signal_name: &str,
    callback: impl SignalCallback + 'static
) -> Result<Self, ()>
[src]

Hook a signal.

Arguments

  • signal_name - The signal to hook (wildcard * is allowed).

  • callback - A function or a struct that implements SignalCallback, the callback method of the trait will be called when the signal is fired.

Panics

Panics if the method is not called from the main Weechat thread.

Example

let signal_hook = SignalHook::new(
    "buffer_switch",
    |_weechat: &Weechat, _signal_name: &str, data: Option<SignalData>| {
        if let Some(data) = data {
            match data {
                SignalData::Buffer(buffer) => {
                    buffer.print("Switched buffer")
                }
                _ => (),
            }
        }

        ReturnCode::Ok
    },
);

Auto Trait Implementations

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.