pub trait RequestConnection {
type Buf: AsRef<[u8]> + Debug + Send + Sync + 'static;
Show 20 methods
// Required methods
fn send_request_with_reply<R>(
&self,
bufs: &[IoSlice<'_>],
fds: Vec<RawFdContainer>,
) -> Result<Cookie<'_, Self, R>, ConnectionError>
where R: TryParse;
fn send_request_with_reply_with_fds<R>(
&self,
bufs: &[IoSlice<'_>],
fds: Vec<RawFdContainer>,
) -> Result<CookieWithFds<'_, Self, R>, ConnectionError>
where R: TryParseFd;
fn send_request_without_reply(
&self,
bufs: &[IoSlice<'_>],
fds: Vec<RawFdContainer>,
) -> Result<VoidCookie<'_, Self>, ConnectionError>;
fn discard_reply(
&self,
sequence: SequenceNumber,
kind: RequestKind,
mode: DiscardMode,
);
fn prefetch_extension_information(
&self,
extension_name: &'static str,
) -> Result<(), ConnectionError>;
fn extension_information(
&self,
extension_name: &'static str,
) -> Result<Option<ExtensionInformation>, ConnectionError>;
fn wait_for_reply_or_raw_error(
&self,
sequence: SequenceNumber,
) -> Result<ReplyOrError<Self::Buf>, ConnectionError>;
fn wait_for_reply(
&self,
sequence: SequenceNumber,
) -> Result<Option<Self::Buf>, ConnectionError>;
fn wait_for_reply_with_fds_raw(
&self,
sequence: SequenceNumber,
) -> Result<ReplyOrError<BufWithFds<Self::Buf>, Self::Buf>, ConnectionError>;
fn check_for_raw_error(
&self,
sequence: SequenceNumber,
) -> Result<Option<Self::Buf>, ConnectionError>;
fn prefetch_maximum_request_bytes(&self);
fn maximum_request_bytes(&self) -> usize;
fn parse_error(&self, error: &[u8]) -> Result<X11Error, ParseError>;
fn parse_event(&self, event: &[u8]) -> Result<Event, ParseError>;
// Provided methods
fn send_trait_request_with_reply<R>(
&self,
request: R,
) -> Result<Cookie<'_, Self, <R as ReplyRequest>::Reply>, ConnectionError>
where R: ReplyRequest { ... }
fn send_trait_request_with_reply_with_fds<R>(
&self,
request: R,
) -> Result<CookieWithFds<'_, Self, R::Reply>, ConnectionError>
where R: ReplyFDsRequest { ... }
fn send_trait_request_without_reply<R>(
&self,
request: R,
) -> Result<VoidCookie<'_, Self>, ConnectionError>
where R: VoidRequest { ... }
fn wait_for_reply_or_error(
&self,
sequence: SequenceNumber,
) -> Result<Self::Buf, ReplyError> { ... }
fn wait_for_reply_with_fds(
&self,
sequence: SequenceNumber,
) -> Result<BufWithFds<Self::Buf>, ReplyError> { ... }
fn check_for_error(
&self,
sequence: SequenceNumber,
) -> Result<(), ReplyError> { ... }
}
Expand description
A connection to an X11 server for sending requests.
This trait only contains functions that are used by other parts of this library. This means that users of this library will most likely not need these functions, unless they want to implement their own X11 connection.
Required Associated Types§
Required Methods§
Sourcefn send_request_with_reply<R>(
&self,
bufs: &[IoSlice<'_>],
fds: Vec<RawFdContainer>,
) -> Result<Cookie<'_, Self, R>, ConnectionError>where
R: TryParse,
fn send_request_with_reply<R>(
&self,
bufs: &[IoSlice<'_>],
fds: Vec<RawFdContainer>,
) -> Result<Cookie<'_, Self, R>, ConnectionError>where
R: TryParse,
Send a request with a reply to the server.
The bufs
parameter describes the raw bytes that should be sent. The returned cookie
allows to get the response.
The fds
parameter contains a list of file descriptors that should be sent with the
request. Ownership of these FDs is transferred to the connection. This means that the
connection will close the FDs after they were sent.
Users of this library will most likely not want to use this function directly. Instead, the generated code will take the supplied arguments, construct byte buffers, and call this method.
The provided buffers must contain at least a single element and the first buffer must have at least four bytes. The length field must be set correctly, unless the request is larger than 2^18 bytes, because in this case, the length field would overflow. The connection automatically uses the BIG-REQUESTS extension for such large requests.
In any case, the request may not be larger than the server’s maximum request length.
Sourcefn send_request_with_reply_with_fds<R>(
&self,
bufs: &[IoSlice<'_>],
fds: Vec<RawFdContainer>,
) -> Result<CookieWithFds<'_, Self, R>, ConnectionError>where
R: TryParseFd,
fn send_request_with_reply_with_fds<R>(
&self,
bufs: &[IoSlice<'_>],
fds: Vec<RawFdContainer>,
) -> Result<CookieWithFds<'_, Self, R>, ConnectionError>where
R: TryParseFd,
Send a request with a reply containing file descriptors to the server.
The bufs
parameter describes the raw bytes that should be sent. The returned cookie
allows to get the response.
The fds
parameter contains a list of file descriptors that should be sent with the
request. Ownership of these FDs is transferred to the connection. This means that the
connection will close the FDs after they were sent.
Users of this library will most likely not want to use this function directly. Instead, the generated code will take the supplied arguments, construct byte buffers, and call this method.
The provided buffers must contain at least a single element and the first buffer must have at least four bytes. The length field must be set correctly, unless the request is larger than 2^18 bytes, because in this case, the length field would overflow. The connection automatically uses the BIG-REQUESTS extension for such large requests.
In any case, the request may not be larger than the server’s maximum request length.
Sourcefn send_request_without_reply(
&self,
bufs: &[IoSlice<'_>],
fds: Vec<RawFdContainer>,
) -> Result<VoidCookie<'_, Self>, ConnectionError>
fn send_request_without_reply( &self, bufs: &[IoSlice<'_>], fds: Vec<RawFdContainer>, ) -> Result<VoidCookie<'_, Self>, ConnectionError>
Send a request without a reply to the server.
The bufs
parameter describes the raw bytes that should be sent. The sequence number of
the request is returned, but most likely not useful to users.
The fds
parameter contains a list of file descriptors that should be sent with the
request. Ownership of these FDs is transferred to the connection. This means that the
connection will close the FDs after they were sent.
Users of this library will most likely not want to use this function directly. Instead, the generated code will take the supplied arguments, construct byte buffers, and call this method.
The provided buffers must contain at least a single element and the first buffer must have at least four bytes. The length field must be set correctly, unless the request is larger than 2^18 bytes, because in this case, the length field would overflow. The connection automatically uses the BIG-REQUESTS extension for such large requests.
In any case, the request may not be larger than the server’s maximum request length.
Sourcefn discard_reply(
&self,
sequence: SequenceNumber,
kind: RequestKind,
mode: DiscardMode,
)
fn discard_reply( &self, sequence: SequenceNumber, kind: RequestKind, mode: DiscardMode, )
A reply to an error should be discarded.
This method is automatically called by the Drop
implementation on Cookie
so that any
replies that are received later can be ignored.
Users of this library will most likely not want to use this function directly.
Sourcefn prefetch_extension_information(
&self,
extension_name: &'static str,
) -> Result<(), ConnectionError>
fn prefetch_extension_information( &self, extension_name: &'static str, ) -> Result<(), ConnectionError>
Prefetches information about an extension.
If the information of a extension is not cached yet, this function sends a
QueryExtension
request, but it does not wait for the reply.
You can use extension_information()
to get the reply of such request.
Using this function can help to reduce round-trip latency, but you can use
extension_information()
directly without calling this function first.
Sourcefn extension_information(
&self,
extension_name: &'static str,
) -> Result<Option<ExtensionInformation>, ConnectionError>
fn extension_information( &self, extension_name: &'static str, ) -> Result<Option<ExtensionInformation>, ConnectionError>
Get information about an extension.
To send a request for some extension, information about the extension (major opcode, first event code and first error code) is necessary. This function provides this information.
The returned object is guaranteed to have a non-zero present
field. Extensions that are
not present are instead returned as None
.
Sourcefn wait_for_reply_or_raw_error(
&self,
sequence: SequenceNumber,
) -> Result<ReplyOrError<Self::Buf>, ConnectionError>
fn wait_for_reply_or_raw_error( &self, sequence: SequenceNumber, ) -> Result<ReplyOrError<Self::Buf>, ConnectionError>
Wait for the reply to a request.
The given sequence number identifies the request for which replies are expected. If the X11
server answered the request with an error, that error is returned as an Err
.
Users of this library will most likely not want to use this function directly.
Sourcefn wait_for_reply(
&self,
sequence: SequenceNumber,
) -> Result<Option<Self::Buf>, ConnectionError>
fn wait_for_reply( &self, sequence: SequenceNumber, ) -> Result<Option<Self::Buf>, ConnectionError>
Wait for the reply to a request.
The given sequence number identifies the request for which replies are expected. If the X11
server answered the request with an error, this function returns None
and the error is
instead returned by wait_for_event()
or poll_for_event()
.
Users of this library will most likely not want to use this function directly.
Sourcefn wait_for_reply_with_fds_raw(
&self,
sequence: SequenceNumber,
) -> Result<ReplyOrError<BufWithFds<Self::Buf>, Self::Buf>, ConnectionError>
fn wait_for_reply_with_fds_raw( &self, sequence: SequenceNumber, ) -> Result<ReplyOrError<BufWithFds<Self::Buf>, Self::Buf>, ConnectionError>
Wait for the reply to a request that has FDs.
The given sequence number identifies the request for which replies are expected.
Users of this library will most likely not want to use this function directly.
Sourcefn check_for_raw_error(
&self,
sequence: SequenceNumber,
) -> Result<Option<Self::Buf>, ConnectionError>
fn check_for_raw_error( &self, sequence: SequenceNumber, ) -> Result<Option<Self::Buf>, ConnectionError>
Check whether a request that does not have a reply caused an X11 error.
The given sequence number identifies the request for which the check should be performed.
Users of this library will most likely not want to use this function directly.
Sourcefn prefetch_maximum_request_bytes(&self)
fn prefetch_maximum_request_bytes(&self)
Prefetches the maximum request length.
If the maximum request length is not cached yet, this function sends a BigRequests::Enable
request, but it does not wait for the reply.
You can use maximum_request_bytes()
to get the result of this request.
Using this function can help to reduce round-trip latency, but you can use
maximum_request_bytes()
directly without calling this function first.
Since this uses the BigRequests
extension, the information about that extension needs to
available. Otherwise, this has to wait for the reply when calling
extension_information()
.
To prefetch the necessary information, you can do the following:
use x11rb::connection::RequestConnection;
use x11rb::errors::ConnectionError;
use x11rb::protocol::bigreq;
// conn is a RequestConnection
conn.prefetch_extension_information(bigreq::X11_EXTENSION_NAME)?;
Sourcefn maximum_request_bytes(&self) -> usize
fn maximum_request_bytes(&self) -> usize
The maximum number of bytes that the X11 server accepts in a request.
Sourcefn parse_error(&self, error: &[u8]) -> Result<X11Error, ParseError>
fn parse_error(&self, error: &[u8]) -> Result<X11Error, ParseError>
Parse a generic error.
Sourcefn parse_event(&self, event: &[u8]) -> Result<Event, ParseError>
fn parse_event(&self, event: &[u8]) -> Result<Event, ParseError>
Parse a generic event.
Provided Methods§
Sourcefn send_trait_request_with_reply<R>(
&self,
request: R,
) -> Result<Cookie<'_, Self, <R as ReplyRequest>::Reply>, ConnectionError>where
R: ReplyRequest,
fn send_trait_request_with_reply<R>(
&self,
request: R,
) -> Result<Cookie<'_, Self, <R as ReplyRequest>::Reply>, ConnectionError>where
R: ReplyRequest,
Send a request with a reply to the server.
This function is a wrapper around RequestConnection::send_request_with_reply
. This
function gets a [ReplyRequest
] as its argument to specify the request to send.
Sourcefn send_trait_request_with_reply_with_fds<R>(
&self,
request: R,
) -> Result<CookieWithFds<'_, Self, R::Reply>, ConnectionError>where
R: ReplyFDsRequest,
fn send_trait_request_with_reply_with_fds<R>(
&self,
request: R,
) -> Result<CookieWithFds<'_, Self, R::Reply>, ConnectionError>where
R: ReplyFDsRequest,
Send a request with a reply containing file descriptors to the server.
This function is a wrapper around RequestConnection::send_request_with_reply_with_fds
.
This function gets a [ReplyFDsRequest
] as its argument to specify the request to send.
Sourcefn send_trait_request_without_reply<R>(
&self,
request: R,
) -> Result<VoidCookie<'_, Self>, ConnectionError>where
R: VoidRequest,
fn send_trait_request_without_reply<R>(
&self,
request: R,
) -> Result<VoidCookie<'_, Self>, ConnectionError>where
R: VoidRequest,
Send a request without a reply to the server.
This function is a wrapper around RequestConnection::send_request_without_reply
. This
function gets a [VoidRequest
] as its argument to specify the request to send.
Sourcefn wait_for_reply_or_error(
&self,
sequence: SequenceNumber,
) -> Result<Self::Buf, ReplyError>
fn wait_for_reply_or_error( &self, sequence: SequenceNumber, ) -> Result<Self::Buf, ReplyError>
Wait for the reply to a request.
The given sequence number identifies the request for which replies are expected. If the X11
server answered the request with an error, that error is returned as an Err
.
Users of this library will most likely not want to use this function directly.
Sourcefn wait_for_reply_with_fds(
&self,
sequence: SequenceNumber,
) -> Result<BufWithFds<Self::Buf>, ReplyError>
fn wait_for_reply_with_fds( &self, sequence: SequenceNumber, ) -> Result<BufWithFds<Self::Buf>, ReplyError>
Wait for the reply to a request that has FDs.
The given sequence number identifies the request for which replies are expected.
Users of this library will most likely not want to use this function directly.
Sourcefn check_for_error(&self, sequence: SequenceNumber) -> Result<(), ReplyError>
fn check_for_error(&self, sequence: SequenceNumber) -> Result<(), ReplyError>
Check whether a request that does not have a reply caused an X11 error.
The given sequence number identifies the request for which the check should be performed.
Users of this library will most likely not want to use this function directly.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.