pub struct Connection { /* private fields */ }
Expand description

The Wayland connection

This is the main type representing your connection to the Wayland server, though most of the interaction with the protocol are actually done using other types. The two main an simple app as for the Connection are:

It can be created through the connect_to_env() method to follow the configuration from the environment (which is what you’ll do most of the time), or using the from_socket() method if you retrieved your connected Wayland socket through other means.

In case you need to plug yourself into an external Wayland connection that you don’t control, you’ll likely get access to it as a Backend, in which case you can create a Connection from it using the from_backend method.

Implementations

Try to connect to the Wayland server following the environment

This is the standard way to initialize a Wayland connection.

Initialize a Wayland connection from an already existing Unix stream

Get the WlDisplay associated with this connection

Create a new event queue

Wrap an existing Backend into a Connection

Get the Backend underlying this Connection

Flush pending outgoing events to the server

This needs to be done regularly to ensure the server receives all your requests, though several dispatching methods do it implicitly (this is stated in their documentation when they do).

Start a synchronized read from the socket

This is needed if you plan to wait on readiness of the Wayland socket using an event loop. See ReadEventsGuard for details. Once the events are received, you’ll then need to dispatch them from their event queues using EventQueue::dispatch_pending().

If you don’t need to manage multiple event sources, see blocking_dispatch() for a simpler mechanism. EventQueue has an identical method for convenience.

Block until events are received from the server

This will flush the outgoing socket, and then block until events are received from the server and read them. You’ll then need to invoke EventQueue::dispatch_pending() to dispatch them on their respective event queues. Alternatively, EventQueue::blocking_dispatch() does the same thing as this method but also dispatches the pending messages on the queue it was invoked.

If you created objects bypassing the event queues with direct ObjectData callbacks, those callbacks will be invoked (if those objects received any events) before this method returns.

Do a roundtrip to the server

This method will block until the Wayland server has processed and answered all your preceding requests. This is notably useful during the initial setup of an app, to wait for the initial state from the server.

See EventQueue::roundtrip() for a version that includes the dispatching of the event queue.

Retrieve the protocol error that occured on the connection if any

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

Send a request associated with the provided object

This is a low-level interface used by the code generated by wayland-scanner, you will likely instead use the methods of the types representing each interface, or the Proxy::send_request and Proxy::send_constructor

Get the protocol information related to given object ID

Get the object data for a given object ID

This is a low-level interface used by the code generated by wayland-scanner, a higher-level interface for manipulating the user-data assocated to Dispatch implementations is given as Proxy::data(). Also see Proxy::object_data().

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.