Struct wayland_client::Connection
source · [−]pub struct Connection { /* private fields */ }
Expand description
The Wayland connection
This is the main type representing your connection to the Wayland server. Most operations require
access to either this type or the ConnectionHandle
, which can be accessed through the
handle()
method, and is given to you in most callbacks.
Implementations
sourceimpl Connection
impl Connection
sourcepub fn handle(&self) -> ConnectionHandle<'_>
pub fn handle(&self) -> ConnectionHandle<'_>
Access the connection handle
sourcepub fn connect_to_env() -> Result<Connection, ConnectError>
pub fn connect_to_env() -> Result<Connection, ConnectError>
Try to connect to the Wayland server following the environment
This is the standard way to initialize a Wayland connection.
sourcepub fn from_socket(stream: UnixStream) -> Result<Connection, ConnectError>
pub fn from_socket(stream: UnixStream) -> Result<Connection, ConnectError>
Initialize a Wayland connection from an already existing Unix stream
sourcepub fn from_backend(backend: Arc<Mutex<Backend>>) -> Connection
pub fn from_backend(backend: Arc<Mutex<Backend>>) -> Connection
Wrap an existing Backend
into a Connection
sourcepub fn flush(&self) -> Result<(), WaylandError>
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.
sourcepub fn prepare_read(&self) -> Result<ReadEventsGuard, WaylandError>
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 the event queue using
EventQueue::dispatch_pending()
.
If you don’t need to manage multiple event sources, see
blocking_dispatch()
for a simpler mechanism.
sourcepub fn blocking_dispatch(&self) -> Result<usize, WaylandError>
pub fn blocking_dispatch(&self) -> Result<usize, WaylandError>
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 both.
sourcepub fn roundtrip(&self) -> Result<usize, WaylandError>
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.
sourcepub fn new_event_queue<D>(&self) -> EventQueue<D>
pub fn new_event_queue<D>(&self) -> EventQueue<D>
Create a new event queue
sourcepub fn protocol_error(&self) -> Option<ProtocolError>
pub fn protocol_error(&self) -> Option<ProtocolError>
Retrive the protocol error that occured on the socket (if any)
Trait Implementations
sourceimpl Clone for Connection
impl Clone for Connection
sourcefn clone(&self) -> Connection
fn clone(&self) -> Connection
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
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