pub struct Cookie<'a, C, R>where
C: RequestConnection + ?Sized,{
raw_cookie: RawCookie<'a, C>,
phantom: PhantomData<R>,
}
Expand description
A handle to a response from the X11 server.
When sending a request to the X11 server, this library returns a Cookie
. This Cookie
can
then later be used to get the response that the server sent.
See crate::cookie for infos on the different ways to handle X11 errors in response to a request.
Fields§
§phantom: PhantomData<R>
Implementations§
source§impl<C, R> Cookie<'_, C, R>
impl<C, R> Cookie<'_, C, R>
sourcepub fn new(connection: &C, sequence_number: SequenceNumber) -> Cookie<'_, C, R>
pub fn new(connection: &C, sequence_number: SequenceNumber) -> Cookie<'_, C, R>
Construct a new cookie.
This function should only be used by implementations of
RequestConnection::send_request_with_reply
.
sourcepub fn sequence_number(&self) -> SequenceNumber
pub fn sequence_number(&self) -> SequenceNumber
Get the sequence number of the request that generated this cookie.
sourcepub fn raw_reply(self) -> Result<C::Buf, ReplyError>
pub fn raw_reply(self) -> Result<C::Buf, ReplyError>
Get the raw reply that the server sent.
sourcepub fn raw_reply_unchecked(self) -> Result<Option<C::Buf>, ConnectionError>
pub fn raw_reply_unchecked(self) -> Result<Option<C::Buf>, ConnectionError>
Get the raw reply that the server sent, but have errors handled as events.
sourcepub fn reply(self) -> Result<R, ReplyError>
pub fn reply(self) -> Result<R, ReplyError>
Get the reply that the server sent.
sourcepub fn reply_unchecked(self) -> Result<Option<R>, ConnectionError>
pub fn reply_unchecked(self) -> Result<Option<R>, ConnectionError>
Get the reply that the server sent, but have errors handled as events.
sourcepub fn discard_reply_and_errors(self)
pub fn discard_reply_and_errors(self)
Discard all responses to the request this cookie represents, even errors.
Without this function, errors are treated as events after the cookie is dropped.
sourcepub(crate) fn into_sequence_number(self) -> SequenceNumber
pub(crate) fn into_sequence_number(self) -> SequenceNumber
Consume this instance and get the contained sequence number out.
sourcepub(crate) fn replace_connection<C2: RequestConnection + ?Sized>(
self,
connection: &C2,
) -> Cookie<'_, C2, R>
pub(crate) fn replace_connection<C2: RequestConnection + ?Sized>( self, connection: &C2, ) -> Cookie<'_, C2, R>
Move this cookie to refer to another connection instance.
This function may only be used if both connections are “basically the same”. For example, a
Cookie for a connection C
can be moved to Rc<C>
since that still refers to the same
underlying connection.