Struct wayland_client::backend::Backend
source · [−]pub struct Backend { /* private fields */ }
Expand description
A Wayland client backend
This type hosts all the interface for interacting with the wayland protocol. It can be cloned, all clones refer to the same underlying connection.
Implementations
sourceimpl Backend
impl Backend
sourcepub fn connect(stream: UnixStream) -> Result<Backend, NoWaylandLib>
pub fn connect(stream: UnixStream) -> Result<Backend, NoWaylandLib>
Try to initialize a Wayland backend on the provided unix stream
The provided stream should correspond to an already established unix connection with the Wayland server. On this rust backend, this method never fails.
sourcepub fn downgrade(&self) -> WeakBackend
pub fn downgrade(&self) -> WeakBackend
Get a WeakBackend
from this backend
sourcepub fn flush(&self) -> Result<(), WaylandError>
pub fn flush(&self) -> Result<(), WaylandError>
Flush all pending outgoing requests to the server
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() -> ObjectId
pub fn null_id() -> ObjectId
Create a null object ID
This object ID is always invalid, and can be used as placeholder.
sourcepub fn send_request(
&self,
msg: Message<ObjectId>,
data: Option<Arc<dyn ObjectData + 'static>>,
child_spec: Option<(&'static Interface, u32)>
) -> Result<ObjectId, InvalidId>
pub fn send_request(
&self,
msg: Message<ObjectId>,
data: Option<Arc<dyn ObjectData + 'static>>,
child_spec: Option<(&'static Interface, u32)>
) -> 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
null_id()
must be given in the argument list at the appropriate place, and achild_spec
(interface and version) can be provided. If one is provided, it’ll be checked agains the protocol spec.
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(
&self,
id: ObjectId,
data: Arc<dyn ObjectData + 'static>
) -> Result<(), InvalidId>
pub fn set_data(
&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).
sourcepub fn prepare_read(&self) -> Result<ReadEventsGuard, WaylandError>
pub fn prepare_read(&self) -> Result<ReadEventsGuard, WaylandError>
Create a new reading guard
This call will not block, but event callbacks may be invoked in the process of preparing the guard.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Backend
impl Send for Backend
impl Sync for Backend
impl Unpin for Backend
impl UnwindSafe for Backend
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more