[−][src]Trait x11rb::connection::RequestConnection
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.
Associated Types
type Buf: AsRef<[u8]> + Debug + Send + Sync + 'static
Type used as buffer to store raw replies or events before they are parsed.
Required methods
fn send_request_with_reply<R>(
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<Cookie<Self, R>, ConnectionError> where
R: for<'a> TryFrom<&'a [u8], Error = ParseError>,
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<Cookie<Self, R>, ConnectionError> where
R: for<'a> TryFrom<&'a [u8], Error = ParseError>,
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.
fn send_request_with_reply_with_fds<R>(
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<CookieWithFds<Self, R>, ConnectionError> where
R: for<'a> TryFrom<(&'a [u8], Vec<RawFdContainer>), Error = ParseError>,
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<CookieWithFds<Self, R>, ConnectionError> where
R: for<'a> TryFrom<(&'a [u8], Vec<RawFdContainer>), Error = ParseError>,
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.
fn send_request_without_reply(
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<VoidCookie<Self>, ConnectionError>
&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.
fn discard_reply(
&self,
sequence: SequenceNumber,
kind: RequestKind,
mode: DiscardMode
)
&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.
fn prefetch_extension_information(
&self,
extension_name: &'static str
) -> Result<(), ConnectionError>
&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.
fn extension_information(
&self,
extension_name: &'static str
) -> Result<Option<ExtensionInformation>, ConnectionError>
&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
.
fn wait_for_reply_or_raw_error(
&self,
sequence: SequenceNumber
) -> Result<ReplyOrError<Self::Buf>, ConnectionError>
&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.
fn wait_for_reply(
&self,
sequence: SequenceNumber
) -> Result<Option<Self::Buf>, ConnectionError>
&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.
fn wait_for_reply_with_fds_raw(
&self,
sequence: SequenceNumber
) -> Result<ReplyOrError<BufWithFds<Self::Buf>, Self::Buf>, ConnectionError>
&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.
fn check_for_raw_error(
&self,
sequence: SequenceNumber
) -> Result<Option<Self::Buf>, ConnectionError>
&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.
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)?;
fn maximum_request_bytes(&self) -> usize
The maximum number of bytes that the X11 server accepts in a request.
fn parse_error(&self, error: &[u8]) -> Result<Error, ParseError>
Parse a generic error.
fn parse_event(&self, event: &[u8]) -> Result<Event, ParseError>
Parse a generic event.
Provided methods
fn wait_for_reply_or_error(
&self,
sequence: SequenceNumber
) -> Result<Self::Buf, ReplyError>
&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.
fn wait_for_reply_with_fds(
&self,
sequence: SequenceNumber
) -> Result<BufWithFds<Self::Buf>, ReplyError>
&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.
fn check_for_error(
&self,
sequence: SequenceNumber
) -> Result<Option<Error>, ConnectionError>
&self,
sequence: SequenceNumber
) -> Result<Option<Error>, 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.
Implementors
impl RequestConnection for XCBConnection
[src]
type Buf = CSlice
fn send_request_with_reply<R>(
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<Cookie<Self, R>, ConnectionError> where
R: for<'a> TryFrom<&'a [u8], Error = ParseError>,
[src]
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<Cookie<Self, R>, ConnectionError> where
R: for<'a> TryFrom<&'a [u8], Error = ParseError>,
fn send_request_with_reply_with_fds<R>(
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<CookieWithFds<Self, R>, ConnectionError> where
R: for<'a> TryFrom<(&'a [u8], Vec<RawFdContainer>), Error = ParseError>,
[src]
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<CookieWithFds<Self, R>, ConnectionError> where
R: for<'a> TryFrom<(&'a [u8], Vec<RawFdContainer>), Error = ParseError>,
fn send_request_without_reply(
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<VoidCookie<Self>, ConnectionError>
[src]
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<VoidCookie<Self>, ConnectionError>
fn discard_reply(
&self,
sequence: SequenceNumber,
_kind: RequestKind,
mode: DiscardMode
)
[src]
&self,
sequence: SequenceNumber,
_kind: RequestKind,
mode: DiscardMode
)
fn prefetch_extension_information(
&self,
extension_name: &'static str
) -> Result<(), ConnectionError>
[src]
&self,
extension_name: &'static str
) -> Result<(), ConnectionError>
fn extension_information(
&self,
extension_name: &'static str
) -> Result<Option<ExtensionInformation>, ConnectionError>
[src]
&self,
extension_name: &'static str
) -> Result<Option<ExtensionInformation>, ConnectionError>
fn wait_for_reply_or_raw_error(
&self,
sequence: SequenceNumber
) -> Result<ReplyOrError<CSlice>, ConnectionError>
[src]
&self,
sequence: SequenceNumber
) -> Result<ReplyOrError<CSlice>, ConnectionError>
fn wait_for_reply(
&self,
sequence: SequenceNumber
) -> Result<Option<CSlice>, ConnectionError>
[src]
&self,
sequence: SequenceNumber
) -> Result<Option<CSlice>, ConnectionError>
fn wait_for_reply_with_fds_raw(
&self,
sequence: SequenceNumber
) -> Result<ReplyOrError<BufWithFds, <XCBConnection as RequestConnection>::Buf>, ConnectionError>
[src]
&self,
sequence: SequenceNumber
) -> Result<ReplyOrError<BufWithFds, <XCBConnection as RequestConnection>::Buf>, ConnectionError>
fn check_for_raw_error(
&self,
sequence: SequenceNumber
) -> Result<Option<<XCBConnection as RequestConnection>::Buf>, ConnectionError>
[src]
&self,
sequence: SequenceNumber
) -> Result<Option<<XCBConnection as RequestConnection>::Buf>, ConnectionError>
fn maximum_request_bytes(&self) -> usize
[src]
fn prefetch_maximum_request_bytes(&self)
[src]
fn parse_error(&self, error: &[u8]) -> Result<Error, ParseError>
[src]
fn parse_event(&self, event: &[u8]) -> Result<Event, ParseError>
[src]
impl<R: ReadFD, W: WriteFD> RequestConnection for RustConnection<R, W>
[src]
type Buf = Vec<u8>
fn send_request_with_reply<Reply>(
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<Cookie<Self, Reply>, ConnectionError> where
Reply: for<'a> TryFrom<&'a [u8], Error = ParseError>,
[src]
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<Cookie<Self, Reply>, ConnectionError> where
Reply: for<'a> TryFrom<&'a [u8], Error = ParseError>,
fn send_request_with_reply_with_fds<Reply>(
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<CookieWithFds<Self, Reply>, ConnectionError> where
Reply: for<'a> TryFrom<(&'a [u8], Vec<RawFdContainer>), Error = ParseError>,
[src]
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<CookieWithFds<Self, Reply>, ConnectionError> where
Reply: for<'a> TryFrom<(&'a [u8], Vec<RawFdContainer>), Error = ParseError>,
fn send_request_without_reply(
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<VoidCookie<Self>, ConnectionError>
[src]
&self,
bufs: &[IoSlice],
fds: Vec<RawFdContainer>
) -> Result<VoidCookie<Self>, ConnectionError>
fn discard_reply(
&self,
sequence: SequenceNumber,
_kind: RequestKind,
mode: DiscardMode
)
[src]
&self,
sequence: SequenceNumber,
_kind: RequestKind,
mode: DiscardMode
)
fn prefetch_extension_information(
&self,
extension_name: &'static str
) -> Result<(), ConnectionError>
[src]
&self,
extension_name: &'static str
) -> Result<(), ConnectionError>
fn extension_information(
&self,
extension_name: &'static str
) -> Result<Option<ExtensionInformation>, ConnectionError>
[src]
&self,
extension_name: &'static str
) -> Result<Option<ExtensionInformation>, ConnectionError>
fn wait_for_reply_or_raw_error(
&self,
sequence: SequenceNumber
) -> Result<ReplyOrError<Vec<u8>>, ConnectionError>
[src]
&self,
sequence: SequenceNumber
) -> Result<ReplyOrError<Vec<u8>>, ConnectionError>
fn wait_for_reply(
&self,
sequence: SequenceNumber
) -> Result<Option<Vec<u8>>, ConnectionError>
[src]
&self,
sequence: SequenceNumber
) -> Result<Option<Vec<u8>>, ConnectionError>
fn check_for_raw_error(
&self,
sequence: SequenceNumber
) -> Result<Option<<RustConnection as RequestConnection>::Buf>, ConnectionError>
[src]
&self,
sequence: SequenceNumber
) -> Result<Option<<RustConnection as RequestConnection>::Buf>, ConnectionError>
fn wait_for_reply_with_fds_raw(
&self,
sequence: SequenceNumber
) -> Result<ReplyOrError<BufWithFds, <RustConnection as RequestConnection>::Buf>, ConnectionError>
[src]
&self,
sequence: SequenceNumber
) -> Result<ReplyOrError<BufWithFds, <RustConnection as RequestConnection>::Buf>, ConnectionError>