Struct ListenerLocalBuilder

Source
pub struct ListenerLocalBuilder<'a> { /* private fields */ }
Expand description

A builder for registering core event callbacks.

Use Core::add_listener_local to create this and register callbacks that will be called when events of interest occur. After adding callbacks, use register to get back a core::Listener.

§Examples

let core_listener = core.add_listener_local()
    .info(|info| println!("New core info: {info:?}"))
    .done(|id, seq| println!("Object {id} received done with seq {seq:?}"))
    .error(|id, seq, res, message| {
        println!("Object {id} received error with seq {seq:?}, error code {res} and message {message}")
    })
    .register();

Implementations§

Source§

impl<'a> ListenerLocalBuilder<'a>

Source

pub fn info<F>(self, info: F) -> Self
where F: Fn(&Info) + 'static,

Set the core info event callback of the listener.

This event is emitted when first bound to the core or when the hello method is called.

§Callback parameters

info: New core info

§Examples
let core_listener = core.add_listener_local()
    .info(|info| println!("New core info: {info:?}"))
    .register();
Source

pub fn done<F>(self, done: F) -> Self
where F: Fn(u32, AsyncSeq) + 'static,

Set the core done event callback of the listener.

This event is emitted as a result of a sync call with the same seq number.

§Callback parameters

id: Object where the done event occurred
seq: The seq number passed to the sync call that emitted this.

§Examples
let core_listener = core.add_listener_local()
    .done(|id, seq| println!("Object {id} received done with seq {seq:?}"))
    .register();
Source

pub fn error<F>(self, error: F) -> Self
where F: Fn(u32, i32, i32, &str) + 'static,

Set the core error event callback of the listener.

This event is emitted when a fatal (non-recoverable) error has occurred. The id argument is the proxy object where the error occurred, most often in response to a request to that object. The message is a brief description of the error, for (debugging) convenience.

This event is usually also emitted on the proxy object with id id.

§Callback parameters

id: Object where the error occurred
seq: Sequence number that generated the error
res: Error code
message: Error description

§Examples
let core_listener = core.add_listener_local()
    .error(|id, seq, res, message| {
        println!("Object {id} received error with seq {seq:?}, error code {res} and message {message}")
    })
    .register();
Source

pub fn register(self) -> Listener

Subscribe to events and register any provided callbacks.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.