[−][src]Struct weechat::hooks::SignalHook
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]
signal_name: &str,
callback: impl SignalCallback + 'static
) -> Result<Self, ()>
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
impl !RefUnwindSafe for SignalHook
impl !Send for SignalHook
impl !Sync for SignalHook
impl Unpin for SignalHook
impl !UnwindSafe for SignalHook
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, 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>,