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 uses a simple app has 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§

source§

impl Connection

source

pub fn connect_to_env() -> Result<Self, ConnectError>

Try to connect to the Wayland server following the environment

This is the standard way to initialize a Wayland connection.

source

pub fn from_socket(stream: UnixStream) -> Result<Self, ConnectError>

Initialize a Wayland connection from an already existing Unix stream

source

pub fn display(&self) -> WlDisplay

Get the WlDisplay associated with this connection

source

pub fn new_event_queue<State>(&self) -> EventQueue<State>

Create a new event queue

source

pub fn from_backend(backend: Backend) -> Self

Wrap an existing Backend into a Connection

source

pub fn backend(&self) -> Backend

Get the Backend underlying this Connection

source

pub fn flush(&self) -> Result<(), WaylandError>

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

source

pub fn prepare_read(&self) -> Result<ReadEventsGuard, WaylandError>

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.

source

pub fn roundtrip(&self) -> Result<usize, WaylandError>

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.

source

pub fn protocol_error(&self) -> Option<ProtocolError>

Retrieve the protocol error that occured on the connection if any

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

source

pub fn send_request<I: Proxy>( &self, proxy: &I, request: I::Request, data: Option<Arc<dyn ObjectData>> ) -> Result<ObjectId, InvalidId>

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

source

pub fn object_info(&self, id: ObjectId) -> Result<ObjectInfo, InvalidId>

Get the protocol information related to given object ID

source

pub fn get_object_data( &self, id: ObjectId ) -> Result<Arc<dyn ObjectData>, InvalidId>

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§

source§

impl Clone for Connection

source§

fn clone(&self) -> Connection

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Connection

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

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

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

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

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

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.