Skip to main content

GlobalHandler

Trait GlobalHandler 

Source
pub trait GlobalHandler<D>:
    Any
    + Send
    + Sync {
    // Required method
    fn bind(
        self: Arc<Self>,
        handle: &Handle,
        data: &mut D,
        client_id: ClientId,
        global_id: GlobalId,
        object_id: ObjectId,
    ) -> Arc<dyn ObjectData<D>>;

    // Provided methods
    fn can_view(
        &self,
        _client_id: ClientId,
        _client_data: &Arc<dyn ClientData>,
        _global_id: GlobalId,
    ) -> bool { ... }
    fn debug(&self, f: &mut Formatter<'_>) -> Result { ... }
}
Expand description

A trait representing the handling of new bound globals

Required Methods§

Source

fn bind( self: Arc<Self>, handle: &Handle, data: &mut D, client_id: ClientId, global_id: GlobalId, object_id: ObjectId, ) -> Arc<dyn ObjectData<D>>

A global has been bound

Given client bound given global, creating given object.

The method must return the object data for the newly created object.

Provided Methods§

Source

fn can_view( &self, _client_id: ClientId, _client_data: &Arc<dyn ClientData>, _global_id: GlobalId, ) -> bool

Check if given client is allowed to interact with given global

If this function returns false, the client will not be notified of the existence of this global, and any attempt to bind it will result in a protocol error as if the global did not exist.

Default implementation always return true.

Source

fn debug(&self, f: &mut Formatter<'_>) -> Result

Helper for forwarding a Debug implementation of your GlobalHandler type

By default will just print GlobalHandler { ... }

Trait Implementations§

Source§

impl<D: 'static> Debug for dyn GlobalHandler<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§