#[non_exhaustive]pub enum CodecFormat {
Proto,
Json,
}Expand description
Supported codec formats.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Proto
Binary protobuf format.
Json
JSON format.
Fully supported only when the json feature is enabled. The variant
always exists (the wire-protocol enums are codec-total), but with the
feature disabled a proto-only build rejects JSON at the edges: the
server declines JSON content types at negotiation
(from_content_type /
from_codec return None), which yields HTTP 415
for Connect or a gRPC error status for gRPC/gRPC-Web; and message
encode/decode returns
ErrorCode::Unimplemented as a
backstop. Connect error bodies are always JSON regardless.
Implementations§
Source§impl CodecFormat
impl CodecFormat
Sourcepub fn from_content_type(content_type: &str) -> Option<Self>
pub fn from_content_type(content_type: &str) -> Option<Self>
Parse codec format from content type string.
With the json feature disabled (a proto-only build) a JSON content
type returns None instead of CodecFormat::Json, so the server
rejects it as an unsupported media type at content negotiation rather
than accepting it and failing later at decode. The message-level
encode/decode gating remains as a backstop.
Sourcepub fn from_codec(codec: &str) -> Option<Self>
pub fn from_codec(codec: &str) -> Option<Self>
Parse codec format from encoding name (used in GET request query params).
Accepts "proto", and "json" only when the json feature is enabled
(the values used in the encoding query parameter). In a proto-only
build "json" returns None, so a Connect GET requesting the JSON
codec is rejected as an unsupported media type.
Sourcepub fn content_type(&self) -> &'static str
pub fn content_type(&self) -> &'static str
Get the content type string for this format (unary RPC).
Sourcepub fn streaming_content_type(&self) -> &'static str
pub fn streaming_content_type(&self) -> &'static str
Get the streaming content type string for this format.
Sourcepub fn is_streaming_content_type(content_type: &str) -> bool
pub fn is_streaming_content_type(content_type: &str) -> bool
Check if the given content type indicates a streaming request.
With the json feature disabled, the application/connect+json
streaming content type is not recognized (a proto-only build treats it
as an unsupported media type), matching Self::from_content_type.
Trait Implementations§
Source§impl Clone for CodecFormat
impl Clone for CodecFormat
Source§fn clone(&self) -> CodecFormat
fn clone(&self) -> CodecFormat
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 CodecFormat
Source§impl Debug for CodecFormat
impl Debug for CodecFormat
Source§impl Display for CodecFormat
impl Display for CodecFormat
impl Eq for CodecFormat
Source§impl PartialEq for CodecFormat
impl PartialEq for CodecFormat
Source§fn eq(&self, other: &CodecFormat) -> bool
fn eq(&self, other: &CodecFormat) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for CodecFormat
Auto Trait Implementations§
impl Freeze for CodecFormat
impl RefUnwindSafe for CodecFormat
impl Send for CodecFormat
impl Sync for CodecFormat
impl Unpin for CodecFormat
impl UnsafeUnpin for CodecFormat
impl UnwindSafe for CodecFormat
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.