Struct ProxyListenerLocalBuilder

Source
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>

Source

pub fn destroy<F>(self, destroy: F) -> Self
where 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();
Source

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

Set the proxy bound event callback of the listener.

This event is emitted when the proxy is bound to a global id.

§Callback parameters

id: The global id

§Examples
let proxy_listener = proxy.add_listener_local()
    .bound(|id| println!("Proxy has been bound to global {id}"))
    .register();
Source

pub fn removed<F>(self, removed: F) -> Self
where 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();
Source

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

Set the proxy done event callback of the listener.

This event is emitted as a reply to the sync method.

§Callback parameters

seq: The sequence number of the sync call.

§Examples
let proxy_listener = proxy.add_listener_local()
    .done(|seq| println!("Proxy received done with seq {seq}"))
    .register();
Source

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

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();
Source

pub fn register(self) -> ProxyListener

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.