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
sourceimpl Connection
impl Connection
sourcepub fn new() -> Self
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.
sourcepub fn send_request(&mut self, kind: ReplyFdKind) -> Option<SequenceNumber>
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.
sourcepub fn discard_reply(&mut self, seqno: SequenceNumber, mode: DiscardMode)
pub fn discard_reply(&mut self, seqno: SequenceNumber, mode: DiscardMode)
Ignore the reply for a request that was previously sent.
sourcepub fn enqueue_fds(&mut self, fds: Vec<RawFdContainer>)
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.
sourcepub fn enqueue_packet(&mut self, packet: Vec<u8>)
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.
sourcepub fn poll_for_reply_or_error(
&mut self,
sequence: SequenceNumber
) -> Option<BufWithFds>
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.
sourcepub fn prepare_check_for_reply_or_error(
&mut self,
sequence: SequenceNumber
) -> bool
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.
sourcepub fn poll_check_for_reply_or_error(
&mut self,
sequence: SequenceNumber
) -> PollReply
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.
sourcepub fn poll_for_reply(&mut self, sequence: SequenceNumber) -> PollReply
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.
sourcepub fn poll_for_event_with_sequence(&mut self) -> Option<RawEventAndSeqNumber>
pub fn poll_for_event_with_sequence(&mut self) -> Option<RawEventAndSeqNumber>
Get a pending event.
Trait Implementations
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