pub struct HttpStream { /* private fields */ }Expand description
An open event stream, read one whole frame at a time.
Implementations§
Source§impl HttpStream
impl HttpStream
Sourcepub async fn next_event(&mut self) -> Result<Option<SseEvent>, HttpClientError>
pub async fn next_event(&mut self) -> Result<Option<SseEvent>, HttpClientError>
The next complete frame, or None once the peer has finished.
§Errors
HttpClientError::Frame for a terminated block that does not parse,
and HttpClientError::Io for a transport failure mid-body.
None is not the same as a failure. A body that ended on a block
boundary is the peer saying there was nothing more; a body that ended
with bytes still buffered is a connection that dropped mid-event. The
first ends the stream, the second is a resume — which is why
HttpStream::has_partial exists and why this returns Option rather
than erroring on the end.
Sourcepub const fn last_event_id(&self) -> Option<EventId>
pub const fn last_event_id(&self) -> Option<EventId>
The id of the last event delivered, which is what a resume asks for.
Sourcepub const fn last_delivered(&self) -> Option<EventId>
pub const fn last_delivered(&self) -> Option<EventId>
The id of the last event handed to the caller, or None if none has
carried an id.
A resume starts here, so a caller driving this stream itself — rather
than through ResumableStream, which tracks it privately — has no
other way to learn it. Without this the only way to resume is to give
up the cursor the client already knows and guess.
Sourcepub const fn has_partial(&self) -> bool
pub const fn has_partial(&self) -> bool
Whether bytes of an unfinished event are still held.