Trait breadx::display::CanBeAsyncDisplay
source · [−]pub trait CanBeAsyncDisplay: DisplayBase {
fn format_request(
&mut self,
req: &mut RawRequest<'_, '_>,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<u64>>;
fn try_send_request_raw(
&mut self,
req: &mut RawRequest<'_, '_>,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<()>>;
fn try_wait_for_reply_raw(
&mut self,
seq: u64,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<RawReply>>;
fn try_wait_for_event(
&mut self,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<Event>>;
fn try_flush(&mut self, ctx: &mut Context<'_>) -> Result<AsyncStatus<()>>;
fn try_generate_xid(
&mut self,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<u32>>;
fn try_maximum_request_length(
&mut self,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<usize>>;
fn try_check_for_error(
&mut self,
seq: u64,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<()>>;
}
Expand description
A display that can be async, if wrapped in an async runtime.
This trait exposes functions similar to those in Display
, but
instead of blocking and returning a value, they return an
AsyncStatus
if the value is available.
Async runtime hooks should use this trait as the underlying object
for AsyncDisplay
implementations. Objects of this trait can’t
be used in the normal way, since an async runtime is needed to
drive the I/O.
Required Methods
fn format_request(
&mut self,
req: &mut RawRequest<'_, '_>,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<u64>>
fn format_request(
&mut self,
req: &mut RawRequest<'_, '_>,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<u64>>
Partially format the request.
This method tries to format the request in such a way that
it can be passed to [try_send_request_raw
]. If additional
information is needed to complete the request (e.g. extension
info or bigreq), this method is allowed to return a non-ready
status.
This method returns the sequence number of the request, which can be used to wait for the reply.
fn try_send_request_raw(
&mut self,
req: &mut RawRequest<'_, '_>,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<()>>
fn try_send_request_raw(
&mut self,
req: &mut RawRequest<'_, '_>,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<()>>
Partially send the request.
This function actually sends the request to the server. Note
that the request has to be formatted using [format_request
]
before this method is called.
Cancel Safety
This function does not have to be cancel safe. In fact, it is likely impossible to make this cancel safe, since sending a fragment of a request will corrupt the X11 server.
fn try_wait_for_reply_raw(
&mut self,
seq: u64,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<RawReply>>
fn try_wait_for_reply_raw(
&mut self,
seq: u64,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<RawReply>>
Wait for the reply.
This function waits for the reply to the request with the given sequence number. If the reply is not yet available, this function returns a non-ready status.
Cancel Safety
This function should be cancel safe. It should read into some kind of buffer, and then return a ready status if the buffer is completed.
fn try_wait_for_event(
&mut self,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<Event>>
fn try_wait_for_event(
&mut self,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<Event>>
Wait for an event.
This function waits for an event to be available. If an event is not available, this function returns a non-ready status.
Cancel Safety
This function should be cancel safe. It should read into some kind of buffer, and then return a ready status if the buffer is completed.
Flush the output buffer.
This function flushes the output buffer. If the output buffer cannot be emptied, this function returns a non-ready status.
Cancel Safety
This function doesn’t have to be cancel safe. It is likely impossible to make this cancel safe, since flushing the output buffer only partially will corrupt the X11 server.
fn try_generate_xid(
&mut self,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<u32>>
fn try_generate_xid(
&mut self,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<u32>>
Generate a unique XID.
This function generates a unique XID. It may involve
try_send_request_raw
, so it has to be partial.
Cancel Safety
This function doesn’t have to be cancel safe.
fn try_maximum_request_length(
&mut self,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<usize>>
fn try_maximum_request_length(
&mut self,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<usize>>
Get the maximum length of a request that can be sent.
This function returns the maximum length of a request that can be sent.
Cancel Safety
This function doesn’t have to be cancel safe.
fn try_check_for_error(
&mut self,
seq: u64,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<()>>
fn try_check_for_error(
&mut self,
seq: u64,
ctx: &mut Context<'_>
) -> Result<AsyncStatus<()>>
Try to check for an error.