#[non_exhaustive]pub enum ClientEvent<'a> {
Response(ResponseHead<'a>),
Body(&'a [u8]),
ResponseEnd,
NeedInput,
Idle,
Upgraded,
Closed,
}Expand description
What a ClientConn has for the caller after poll.
§Examples
use http_net::{ClientConn, ClientEvent, Request};
let mut conn = ClientConn::new();
let mut out = Vec::new();
conn.send_request(&Request::get("/").header("host", "example.com"), &mut out).unwrap();
let _ = conn.feed(b"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n3\r\nabc\r\n0\r\n\r\n");
let mut body = Vec::new();
loop {
match conn.poll().unwrap() {
ClientEvent::Response(resp) => assert_eq!(resp.status(), 200),
ClientEvent::Body(chunk) => body.extend_from_slice(chunk),
ClientEvent::ResponseEnd => break,
other => panic!("{other:?}"),
}
}
assert_eq!(body, b"abc");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Response(ResponseHead<'a>)
The response head arrived (interim 1xx responses other than 101 are
skipped; together they count against
Limits::max_header_bytes). Its
body follows as Body events, then
ResponseEnd.
Body(&'a [u8])
A run of body bytes, after chunked decoding.
ResponseEnd
The response is complete.
NeedInput
More input is needed (or, for a body that runs until close,
feed_eof once the server closes).
Idle
No request is outstanding; send the next one.
Upgraded
The server switched protocols (101 to an upgrade request, or 2xx to
CONNECT); the response head was reported just before. Bytes of the
new protocol that already arrived are in
remaining_input.
Closed
The connection cannot carry another request: close the socket.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ClientEvent<'a>
impl<'a> RefUnwindSafe for ClientEvent<'a>
impl<'a> Send for ClientEvent<'a>
impl<'a> Sync for ClientEvent<'a>
impl<'a> Unpin for ClientEvent<'a>
impl<'a> UnsafeUnpin for ClientEvent<'a>
impl<'a> UnwindSafe for ClientEvent<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more