Struct wayland_client::backend::Handle
source · [−]pub struct Handle { /* 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 Handle
impl Handle
sourcepub fn display_id(&self) -> ObjectId
pub fn display_id(&self) -> ObjectId
Get the object ID for the wl_display
sourcepub fn last_error(&self) -> Option<WaylandError>
pub fn last_error(&self) -> Option<WaylandError>
Get the last error that occurred on this backend
If this returns an error, your Wayland connection is already dead.
sourcepub fn info(&self, id: ObjectId) -> Result<ObjectInfo, InvalidId>
pub fn info(&self, id: ObjectId) -> Result<ObjectInfo, InvalidId>
Get the detailed information about a wayland object
Returns an error if the provided object ID is no longer valid.
sourcepub fn null_id(&mut self) -> ObjectId
pub fn null_id(&mut self) -> ObjectId
Create a null object ID
This object ID is always invalid, and can be used as placeholder.
sourcepub fn placeholder_id(
&mut self,
spec: Option<(&'static Interface, u32)>
) -> ObjectId
pub fn placeholder_id(
&mut self,
spec: Option<(&'static Interface, u32)>
) -> ObjectId
Create a placeholder ID for object creation
This ID needs to be created beforehand and given as argument to a request creating a
new object ID. A specification must be specified if the interface and version cannot
be inferred from the protocol (for example object creation from the wl_registry
).
If a specification is provided it’ll be checked against what can be deduced from the
protocol specification, and send_request
will panic if they
do not match.
sourcepub fn send_request(
&mut self,
msg: Message<ObjectId>,
data: Option<Arc<dyn ObjectData + 'static>>
) -> Result<ObjectId, InvalidId>
pub fn send_request(
&mut self,
msg: Message<ObjectId>,
data: Option<Arc<dyn ObjectData + 'static>>
) -> Result<ObjectId, InvalidId>
Sends a request to the server
Returns an error if the sender ID of the provided message is no longer valid.
Panic:
Several 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
- if the method creates a new object, a
placeholder_id()
must be given in the argument list, either without a specification, or with a specification that matches the interface and version deduced from the protocol rules
sourcepub fn get_data(
&self,
id: ObjectId
) -> Result<Arc<dyn ObjectData + 'static>, InvalidId>
pub fn get_data(
&self,
id: ObjectId
) -> Result<Arc<dyn ObjectData + 'static>, InvalidId>
Access the object data associated with a given object ID
Returns an error if the object ID is not longer valid or if it corresponds to a Wayland
object that is not managed by this backend (when multiple libraries share the same Wayland
socket via libwayland
if using the system backend).
sourcepub fn set_data(
&mut self,
id: ObjectId,
data: Arc<dyn ObjectData + 'static>
) -> Result<(), InvalidId>
pub fn set_data(
&mut self,
id: ObjectId,
data: Arc<dyn ObjectData + 'static>
) -> Result<(), InvalidId>
Set the object data associated with a given object ID
Returns an error if the object ID is not longer valid or if it corresponds to a Wayland
object that is not managed by this backend (when multiple libraries share the same Wayland
socket via libwayland
if using the system backend).
Trait Implementations
sourceimpl<'a> From<&'a mut Handle> for ConnectionHandle<'a>
impl<'a> From<&'a mut Handle> for ConnectionHandle<'a>
sourcefn from(handle: &'a mut Handle) -> Self
fn from(handle: &'a mut Handle) -> Self
Creates a ConnectionHandle
using a &mut Handle
from wayland-backend
.
Auto Trait Implementations
impl !RefUnwindSafe for Handle
impl Send for Handle
impl Sync for Handle
impl Unpin for Handle
impl !UnwindSafe for Handle
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
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn 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
fn 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
fn 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
fn 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