pub enum ContentType {
Show 14 variants
Json,
Yaml,
Cbor,
MsgPack,
Csv,
Proto,
FormUrlEncoded,
MultipartForm,
Sse,
WebSocket,
GrpcWeb,
OpenApi,
Mcp,
Markdown,
}Expand description
Supported content types, transports, and discovery formats.
Copy, stack-allocated, zero-cost to pass around.
Variants§
Json
JSON (application/json) — default
Yaml
YAML (application/yaml)
Cbor
CBOR (application/cbor) — binary
MsgPack
MessagePack (application/msgpack) — binary
Csv
CSV (text/csv) — tabular
Proto
Protobuf (application/proto) — binary, also Connect/gRPC
FormUrlEncoded
Form URL-encoded (application/x-www-form-urlencoded) — request deserialization
MultipartForm
Multipart form data (multipart/form-data) — request deserialization
Sse
Server-Sent Events (text/event-stream)
WebSocket
WebSocket (Upgrade: websocket)
GrpcWeb
gRPC-Web / Connect server-streaming (application/grpc-web+json).
Length-prefixed envelope frames [flag:u8][len:u32 BE][payload]
over a held-open HTTP/2 response — the browser-reachable member of
the gRPC family (raw gRPC needs HTTP/2 trailers the fetch API
can’t read). Shares the subscribe path with Self::Sse; only
the frame encoding differs.
OpenApi
OpenAPI 3.1 spec
Mcp
MCP tools/list response
Markdown
Human-readable Markdown
Implementations§
Source§impl ContentType
impl ContentType
Sourcepub fn from_extension(ext: &str) -> Option<Self>
pub fn from_extension(ext: &str) -> Option<Self>
Parse from URL file extension.
Sourcepub fn from_content_type_header(header: &str) -> Option<Self>
pub fn from_content_type_header(header: &str) -> Option<Self>
Parse from Content-Type request header for transport/format detection.
Returns None for standard types that don’t need special routing.
Sourcepub fn from_accept_header(accept: Option<&str>) -> Self
pub fn from_accept_header(accept: Option<&str>) -> Self
Parse from Accept header value. Falls back to Json.
Sourcepub fn from_query_param(query: &str) -> Option<Self>
pub fn from_query_param(query: &str) -> Option<Self>
Parse from ?format= query parameter.
Sourcepub const fn header_value(self) -> &'static str
pub const fn header_value(self) -> &'static str
Content-Type header value for the response.
Sourcepub const fn is_streaming(self) -> bool
pub const fn is_streaming(self) -> bool
Whether this is a streaming transport (SSE, WebSocket, gRPC-Web).
Sourcepub const fn is_streaming_subscribe(self) -> bool
pub const fn is_streaming_subscribe(self) -> bool
Whether this is a server-to-client streaming-subscribe transport (SSE or gRPC-Web) — the formats the subscribe handler serves over a held-open response. Excludes WebSocket (handled by an upgrade in the host layer before dispatch).
Sourcepub const fn is_data_format(self) -> bool
pub const fn is_data_format(self) -> bool
Whether this is a data serialization format.
Trait Implementations§
Source§impl Clone for ContentType
impl Clone for ContentType
Source§fn clone(&self) -> ContentType
fn clone(&self) -> ContentType
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ContentType
Source§impl Debug for ContentType
impl Debug for ContentType
Source§impl Default for ContentType
impl Default for ContentType
Source§fn default() -> ContentType
fn default() -> ContentType
impl Eq for ContentType
Source§impl Hash for ContentType
impl Hash for ContentType
Source§impl PartialEq for ContentType
impl PartialEq for ContentType
Source§fn eq(&self, other: &ContentType) -> bool
fn eq(&self, other: &ContentType) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ContentType
Auto Trait Implementations§
impl Freeze for ContentType
impl RefUnwindSafe for ContentType
impl Send for ContentType
impl Sync for ContentType
impl Unpin for ContentType
impl UnsafeUnpin for ContentType
impl UnwindSafe for ContentType
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.