[][src]Module x11rb::connection

Generic connection-related types and definitions.

This module contains the Connection trait and related definitions. The code in this module is used by each concrete implementation of the X11 protocol.

Handling X11 errors

The X11 server can answer requests with an error packet for various reasons, e.g. because an invalid window ID was given. There are three options what can be done with errors:

  • Errors can appear as X11 events in wait_for_event() (in XCB, this is called "unchecked")
  • Errors can be checked for locally after a request was sent (in XCB, this is called "checked")
  • Errors can be completely ignored (the closest analog in XCB would be xcb_discard_reply())

There is an additional difference between requests with and without replies.

Requests without a reply

For requests that do not have a reply, you get an instance of VoidCookie after sending the request. The different behaviors can be achieved via interacting with this cookie as foolows:

What?How?
Treat as eventsJust drop the cookie
Check locallyVoidCookie::check
IgnoreVoidCookie::ignore_error

Requests with a reply

For requests with a reply, an additional option is what should happen to the reply. You can get the reply, but any errors are still treated as events. This allows to centralise X11 error handling a bit in case you only want to log errors.

The following things can be done with the Cookie that you get after sending a request with an error.

ReplyErrors locally/ignoredErrors as events
GetCookie::replyCookie::reply_unchecked
IgnoreCookie::discard_reply_and_errorsJust drop the cookie

Enums

DiscardMode

Variants describing which responses to a request should be discarded.

ReplyOrError

Either a raw reply or a raw error response to an X11 request.

RequestKind

Does a request have a response?

Traits

Connection

A connection to an X11 server.

RequestConnection

A connection to an X11 server for sending requests.

Functions

compute_length_field

Check the request length and use BIG-REQUESTS if necessary.

Type Definitions

BufWithFds
EventAndSeqNumber
PiecewiseBuf
RawEventAndSeqNumber
SequenceNumber

Number type used for referring to things that were sent to the server in responses from the server.