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

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.

This method can only fail on the sys backend if the dlopen cargo feature was enabled and the system wayland library could not be found.

Get a WeakBackend from this backend

Flush all pending outgoing requests to the server

Most errors on this method mean that the Wayland connection is no longer valid, the only exception being an IO WouldBlock error. In that case it means that you should try flushing again later.

You can however expect this method returning WouldBlock to be very rare: it can only occur if either your client sent a lot of big messages at once, or the server is very laggy.

Get the object ID for the wl_display

Get the last error that occurred on this backend

If this returns Some, your Wayland connection is already dead.

Get the detailed protocol information about a wayland object

Returns an error if the provided object ID is no longer valid.

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 ObjectId::null() must be given in the argument list at the appropriate place, and a child_spec (interface and version) can be provided. If one is provided, it’ll be checked against the protocol spec. If the protocol specification does not define the interface of the created object (notable example is wl_registry.bind), the child_spec must be provided.

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).

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).

Create a new reading guard

This is the first step for actually reading events from the Wayland socket. See ReadEventsGuard for how to use it.

This call will not block, but event callbacks may be invoked in the process of preparing the guard.

If it returns an error, you Wayland connection is already dead.

Dispatches the inner queue of this backend if necessary

This function is only relevant when using the system backend that was created from an external display. In this case, it is possible that some other part of the program already takes care of reading the wayland socket and you should not touch it, and thus you cannot use prepare_read(). In this situation, this method will ensure that this Backend still correctly processes its messages.

When using the rust backend, or when using the system backend where you own the connection, this function will do nothing. It is thus safe to unconditionnaly invoke it at some point in your library code to ensure you support all use cases, for example.

Returns the number of messages that were dispatched to their ObjectData callbacks.

Creates a Backend from a foreign *mut wl_display.

This is useful if you are writing a library that is expected to plug itself into an existing Wayland connection.

This will initialize the Backend in “guest” mode, meaning it will not close the connection on drop. After the Backend is dropped, if the server sends an event to an object that was created from it, that event will be silently discarded. This may lead to protocol errors if the server expects an answer to that event, as such you should make sure to cleanup your Wayland state before dropping the Backend.

Safety

You need to ensure the *mut wl_display remains live as long as the Backend (or its clones) exist.

Returns the underlying wl_display pointer to this backend.

This pointer is needed to interface with EGL, Vulkan and other C libraries.

This pointer is only valid for the lifetime of the backend.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
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
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
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more
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
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.