pub enum StreamFormat {
Json,
NdJson,
ServerSentEvents,
Binary,
}Expand description
Streaming format types
Variants§
Json
Standard JSON array streaming
NdJson
Newline-delimited JSON
ServerSentEvents
Server-Sent Events
Binary
Binary PJS protocol
Implementations§
Source§impl StreamFormat
impl StreamFormat
Sourcepub fn from_accept_header(headers: &HeaderMap) -> Self
pub fn from_accept_header(headers: &HeaderMap) -> Self
Picks a streaming format for the request’s Accept header.
Negotiation is RFC 9110 §12.5.1-conformant for this route’s supported media
ranges, delegated to headers_accept::Accept::negotiate: candidates are
ranked by q value first and by media-range specificity as the tiebreaker
(exact match > application/* > */*).
q=0is an explicit rejection of that media range and drops the entry.- A
qparameter that is non-finite (nan/inf/-inf) or otherwise fails to parse as a float drops its entry — a malformed preference is treated as “no preference stated”, not “highest preference”. This is validated before delegating toheaders_accept, whose own default treats an unparsableqas absent (i.e.1.0, the highest priority) rather than dropping the entry. - A finite but out-of-range
q(e.g.q=5) is clamped to[0.0, 1.0]and the entry is kept — matching the pre-migration hand-rolled parser’s.clamp(0.0, 1.0)exactly (not dropped; onlyq=0, non-finite, and unparsableqare dropped). - Wildcard matching is restricted to exactly
*/*andapplication/*(case-insensitive), which vote forSelf::Jsonat their ownq. Any other range containing a*(e.g.text/*,*/x-ndjson) is rejected rather than delegated toheaders_accept’s more generaltype/*/*/*matching, which is broader than this route’s historical, scoped wildcard support. - Each surviving entry is validated as a well-formed media type
independently, before negotiation; a malformed entry (e.g.
garbage!!) is dropped individually and does not discard the rest of the header —headers_accept::Accept::from_stritself fails the entire header on a single bad entry, so this crate is never handed anything but already-validated, surviving entries. - At most
MAX_ACCEPT_ENTRIES(16) comma-separated entries are considered; any beyond that bound are silently ignored. This bound is enforced by truncating the raw header string before it reachesheaders_accept’s parser, since that crate does not itself bound entry count. - A missing header, an unparsable header value, or no entry surviving
negotiation all fall back to
Self::Json.
Sourcepub fn content_type(&self) -> &'static str
pub fn content_type(&self) -> &'static str
MIME type that corresponds to this streaming format.
Trait Implementations§
Source§impl Clone for StreamFormat
impl Clone for StreamFormat
Source§fn clone(&self) -> StreamFormat
fn clone(&self) -> StreamFormat
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for StreamFormat
Auto Trait Implementations§
impl Freeze for StreamFormat
impl RefUnwindSafe for StreamFormat
impl Send for StreamFormat
impl Sync for StreamFormat
impl Unpin for StreamFormat
impl UnsafeUnpin for StreamFormat
impl UnwindSafe for StreamFormat
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more