Struct x11rb_protocol::connection::Connection

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

A pure-rust, sans-I/O implementation of the X11 protocol.

This object is designed to be used in combination with an I/O backend, in order to keep state for the X11 protocol.

Implementations§

source§

impl Connection

source

pub fn new() -> Self

Create a new Connection.

It is assumed that the connection was just established. This means that the next request that is sent will have sequence number one.

source

pub fn send_request(&mut self, kind: ReplyFdKind) -> Option<SequenceNumber>

Send a request to the X11 server.

When this returns None, a sync with the server is necessary. Afterwards, the caller should try again.

source

pub fn discard_reply(&mut self, seqno: SequenceNumber, mode: DiscardMode)

Ignore the reply for a request that was previously sent.

source

pub fn enqueue_fds(&mut self, fds: Vec<RawFdContainer>)

Add FDs that were received to the internal state.

This must be called before the corresponding packets are enqueued.

source

pub fn enqueue_packet(&mut self, packet: Vec<u8>)

An X11 packet was received from the connection and is now enqueued into our state.

Any FDs that were received must already be enqueued before this can be called.

source

pub fn poll_for_reply_or_error( &mut self, sequence: SequenceNumber ) -> Option<BufWithFds>

Check if the server already sent an answer to the request with the given sequence number.

This function is meant to be used for requests that have a reply. Such requests always cause a reply or an error to be sent.

source

pub fn prepare_check_for_reply_or_error( &mut self, sequence: SequenceNumber ) -> bool

Prepare for calling poll_check_for_reply_or_error().

To check if a request with a reply caused an error, one simply has to wait for the error or reply to be received. However, this approach does not work for requests without errors: Success is indicated by the absence of an error.

Thus, this function returns true if a sync is necessary to ensure that a reply with a higher sequence number will be received. Since the X11 server handles requests in-order, if the reply to a later request is received, this means that the earlier request did not fail.

source

pub fn poll_check_for_reply_or_error( &mut self, sequence: SequenceNumber ) -> PollReply

Check if the request with the given sequence number was already handled by the server.

Before calling this function, you must call prepare_check_for_reply_or_error() with the sequence number.

This function can be used for requests with and without a reply.

source

pub fn poll_for_reply(&mut self, sequence: SequenceNumber) -> PollReply

Find the reply for the request with the given sequence number.

If the request caused an error, that error will be handled as an event. This means that a latter call to poll_for_event() will return it.

source

pub fn poll_for_event_with_sequence(&mut self) -> Option<RawEventAndSeqNumber>

Get a pending event.

Trait Implementations§

source§

impl Debug for Connection

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Connection

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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, U> TryFrom<U> for T
where 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 T
where 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.