pub struct Handle<D: 'static> { /* private fields */ }Expand description
Main handle of a backend to the Wayland protocol
This type hosts most of the protocol-related functionality of the backend, and is the
main entry point for manipulating Wayland objects. It can be retrieved both from
the backend via Backend::handle(), and is given to you as argument
in most event callbacks.
Implementations
sourceimpl<D> Handle<D>
impl<D> Handle<D>
sourcepub fn object_info(&self, id: ObjectId) -> Result<ObjectInfo, InvalidId>
pub fn object_info(&self, id: ObjectId) -> Result<ObjectInfo, InvalidId>
Returns information about some object.
sourcepub fn get_client(&self, id: ObjectId) -> Result<ClientId, InvalidId>
pub fn get_client(&self, id: ObjectId) -> Result<ClientId, InvalidId>
Returns the id of the client which owns the object.
sourcepub fn get_client_data(
&self,
id: ClientId
) -> Result<Arc<dyn ClientData<D>>, InvalidId>
pub fn get_client_data(
&self,
id: ClientId
) -> Result<Arc<dyn ClientData<D>>, InvalidId>
Returns the data associated with a client.
sourcepub fn get_client_credentials(
&self,
id: ClientId
) -> Result<Credentials, InvalidId>
pub fn get_client_credentials(
&self,
id: ClientId
) -> Result<Credentials, InvalidId>
Retrive the Credentials of a client
sourcepub fn all_clients<'b>(&'b self) -> Box<dyn Iterator<Item = ClientId> + 'b>
pub fn all_clients<'b>(&'b self) -> Box<dyn Iterator<Item = ClientId> + 'b>
Returns an iterator over all clients connected to the server.
sourcepub fn all_objects_for<'b>(
&'b self,
client_id: ClientId
) -> Result<Box<dyn Iterator<Item = ObjectId> + 'b>, InvalidId>
pub fn all_objects_for<'b>(
&'b self,
client_id: ClientId
) -> Result<Box<dyn Iterator<Item = ObjectId> + 'b>, InvalidId>
Returns an iterator over all objects owned by a client.
sourcepub fn object_for_protocol_id(
&self,
client_id: ClientId,
interface: &'static Interface,
protocol_id: u32
) -> Result<ObjectId, InvalidId>
pub fn object_for_protocol_id(
&self,
client_id: ClientId,
interface: &'static Interface,
protocol_id: u32
) -> Result<ObjectId, InvalidId>
Retrieve the ObjectId for a wayland object given its protocol numerical ID
sourcepub fn create_object(
&mut self,
client_id: ClientId,
interface: &'static Interface,
version: u32,
data: Arc<dyn ObjectData<D>>
) -> Result<ObjectId, InvalidId>
pub fn create_object(
&mut self,
client_id: ClientId,
interface: &'static Interface,
version: u32,
data: Arc<dyn ObjectData<D>>
) -> Result<ObjectId, InvalidId>
Create a new object for given client
To ensure state coherence of the protocol, the created object should be immediately sent as a “New ID” argument in an event to the client.
sourcepub fn send_event(&mut self, msg: Message<ObjectId>) -> Result<(), InvalidId>
pub fn send_event(&mut self, msg: Message<ObjectId>) -> Result<(), InvalidId>
Send an event to the client
Returns an error if the sender ID of the provided message is no longer valid.
Panic:
Checks against the protocol specification are done, and this method will panic if they do not pass:
- the message opcode must be valid for the sender interface
- the argument list must match the prototype for the message associated with this opcode
sourcepub fn get_object_data(
&self,
id: ObjectId
) -> Result<Arc<dyn ObjectData<D>>, InvalidId>
pub fn get_object_data(
&self,
id: ObjectId
) -> Result<Arc<dyn ObjectData<D>>, InvalidId>
Returns the data associated with an object.
sourcepub fn set_object_data(
&mut self,
id: ObjectId,
data: Arc<dyn ObjectData<D>>
) -> Result<(), InvalidId>
pub fn set_object_data(
&mut self,
id: ObjectId,
data: Arc<dyn ObjectData<D>>
) -> Result<(), InvalidId>
Sets the data associated with some object.
sourcepub fn post_error(
&mut self,
object_id: ObjectId,
error_code: u32,
message: CString
)
pub fn post_error(
&mut self,
object_id: ObjectId,
error_code: u32,
message: CString
)
Posts an error on an object. This will also disconnect the client which created the object.
sourcepub fn kill_client(&mut self, client_id: ClientId, reason: DisconnectReason)
pub fn kill_client(&mut self, client_id: ClientId, reason: DisconnectReason)
Kills the connection to a client.
The disconnection reason determines the error message that is sent to the client (if any).
sourcepub fn create_global(
&mut self,
interface: &'static Interface,
version: u32,
handler: Arc<dyn GlobalHandler<D>>
) -> GlobalId
pub fn create_global(
&mut self,
interface: &'static Interface,
version: u32,
handler: Arc<dyn GlobalHandler<D>>
) -> GlobalId
Creates a global of the specified interface and version and then advertises it to clients.
The clients which the global is advertised to is determined by the implementation of the GlobalHandler.
sourcepub fn disable_global(&mut self, id: GlobalId)
pub fn disable_global(&mut self, id: GlobalId)
Disables a global object that is currently active.
The global removal will be signaled to all currently connected clients. New clients will not know of the global, but the associated state and callbacks will not be freed. As such, clients that still try to bind the global afterwards (because they have not yet realized it was removed) will succeed.
sourcepub fn remove_global(&mut self, id: GlobalId)
pub fn remove_global(&mut self, id: GlobalId)
Removes a global object and free its ressources.
The global object will no longer be considered valid by the server, clients trying to bind it will be killed, and the global ID is freed for re-use.
It is advised to first disable a global and wait some amount of time before removing it, to ensure all clients
are correctly aware of its removal. Note that clients will generally not expect globals that represent a capability
of the server to be removed, as opposed to globals representing peripherals (like wl_output or wl_seat).
sourcepub fn global_info(&self, id: GlobalId) -> Result<GlobalInfo, InvalidId>
pub fn global_info(&self, id: GlobalId) -> Result<GlobalInfo, InvalidId>
Returns information about a global.
sourcepub fn get_global_handler(
&self,
id: GlobalId
) -> Result<Arc<dyn GlobalHandler<D>>, InvalidId>
pub fn get_global_handler(
&self,
id: GlobalId
) -> Result<Arc<dyn GlobalHandler<D>>, InvalidId>
Returns the handler which manages the visibility and notifies when a client has bound the global.
Trait Implementations
Auto Trait Implementations
impl<D> !RefUnwindSafe for Handle<D>
impl<D> Send for Handle<D>
impl<D> Sync for Handle<D>
impl<D> Unpin for Handle<D>
impl<D> !UnwindSafe for Handle<D>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read more