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>
impl<'a> ListenerLocalBuilder<'a>
Sourcepub fn done<F>(self, done: F) -> Self
pub fn done<F>(self, done: F) -> Self
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();Sourcepub fn error<F>(self, error: F) -> Self
pub fn error<F>(self, error: F) -> Self
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();