pub struct ProxyListenerLocalBuilder<'a> { /* private fields */ }Expand description
A builder for registering proxy event callbacks.
Use Proxy::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 ProxyListener.
§Examples
let proxy_listener = proxy.add_listener_local()
.destroy(|| println!("Proxy has been destroyed"))
.bound(|id| println!("Proxy has been bound to global {id}"))
.removed(|| println!("Proxy has been removed"))
.done(|seq| println!("Proxy received done with seq {seq}"))
.error(|seq, res, message| println!("Proxy error: seq {seq}, error code {res}, message {message}"))
.register();Implementations§
Source§impl<'a> ProxyListenerLocalBuilder<'a>
impl<'a> ProxyListenerLocalBuilder<'a>
Sourcepub fn destroy<F>(self, destroy: F) -> Selfwhere
F: Fn() + 'static,
pub fn destroy<F>(self, destroy: F) -> Selfwhere
F: Fn() + 'static,
Set the proxy destroy event callback of the listener.
This event is emitted when the proxy is destroyed.
§Examples
let proxy_listener = proxy.add_listener_local()
.destroy(|| println!("Proxy has been destroyed"))
.register();Sourcepub fn removed<F>(self, removed: F) -> Selfwhere
F: Fn() + 'static,
pub fn removed<F>(self, removed: F) -> Selfwhere
F: Fn() + 'static,
Set the proxy removed event callback of the listener.
This event is emitted when the proxy is removed from the server. Drop the proxy to free it.
§Examples
let proxy_listener = proxy.add_listener_local()
.removed(|| println!("Proxy has been removed"))
.register();Sourcepub fn error<F>(self, error: F) -> Self
pub fn error<F>(self, error: F) -> Self
Set the proxy error event callback of the listener.
This event is emitted when an error occurs on the proxy.
§Callback parameters
seq: Seqeunce number that generated the error
res: Error code
message: Error description
§Examples
let proxy_listener = proxy.add_listener_local()
.error(|seq, res, message| println!("Proxy error: seq {seq}, error code {res}, message {message}"))
.register();Sourcepub fn register(self) -> ProxyListener
pub fn register(self) -> ProxyListener
Subscribe to events and register any provided callbacks.
Auto Trait Implementations§
impl<'a> Freeze for ProxyListenerLocalBuilder<'a>
impl<'a> !RefUnwindSafe for ProxyListenerLocalBuilder<'a>
impl<'a> !Send for ProxyListenerLocalBuilder<'a>
impl<'a> !Sync for ProxyListenerLocalBuilder<'a>
impl<'a> Unpin for ProxyListenerLocalBuilder<'a>
impl<'a> !UnwindSafe for ProxyListenerLocalBuilder<'a>
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