#[non_exhaustive]pub enum Protocol {
Connect,
Grpc,
GrpcWeb,
}Expand description
The wire protocol used for an RPC.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Connect
Connect protocol - HTTP-native with standard HTTP semantics.
Unary RPCs use bare message bodies and real HTTP status codes. Streaming RPCs use envelope framing with JSON end-of-stream messages.
Grpc
gRPC protocol - standard gRPC over HTTP/2.
All RPCs use envelope framing. Status is communicated via HTTP/2
trailing HEADERS (grpc-status, grpc-message). HTTP status is
always 200.
GrpcWeb
gRPC-Web protocol - gRPC-Web for browser compatibility.
Like gRPC but works over HTTP/1.1. Trailers are encoded in the response body as a final frame with flag byte 0x80.
Implementations§
Source§impl Protocol
impl Protocol
Sourcepub fn detect(headers: &HeaderMap) -> Option<RequestProtocol>
pub fn detect(headers: &HeaderMap) -> Option<RequestProtocol>
Detect the protocol, codec format, and streaming mode from request headers.
Returns None if the Content-Type doesn’t match any known protocol.
Sourcepub fn detect_from_content_type(content_type: &str) -> Option<RequestProtocol>
pub fn detect_from_content_type(content_type: &str) -> Option<RequestProtocol>
Detect the protocol from a Content-Type string.
Returns None if the content type doesn’t match any known protocol.
Sourcepub fn response_content_type(
&self,
format: CodecFormat,
is_streaming: bool,
) -> &'static str
pub fn response_content_type( &self, format: CodecFormat, is_streaming: bool, ) -> &'static str
Get the Content-Type header value for a response with this protocol and codec.
Sourcepub fn timeout_header(&self) -> &'static str
pub fn timeout_header(&self) -> &'static str
Get the timeout header name for this protocol.
Sourcepub fn content_encoding_header(&self) -> &'static HeaderName
pub fn content_encoding_header(&self) -> &'static HeaderName
Get the content-encoding header name for this protocol (streaming).
Returns a pre-parsed HeaderName so callers can pass it directly to
HeaderMap::insert without the from_bytes re-parse that
Response::Builder::header(&str, _) does.
Sourcepub fn accept_encoding_header(&self) -> &'static HeaderName
pub fn accept_encoding_header(&self) -> &'static HeaderName
Get the accept-encoding header name for this protocol (streaming).
Sourcepub fn uses_http_status_codes(&self) -> bool
pub fn uses_http_status_codes(&self) -> bool
Whether this protocol uses real HTTP status codes for errors.
Connect uses standard HTTP status codes for unary errors. gRPC and gRPC-Web always return HTTP 200, with errors in trailers.
Sourcepub fn requires_http2(&self) -> bool
pub fn requires_http2(&self) -> bool
Whether this protocol requires HTTP/2.
Sourcepub fn uses_http_trailers(&self) -> bool
pub fn uses_http_trailers(&self) -> bool
Whether this protocol sends trailers via HTTP/2 HEADERS frames.
gRPC uses HTTP/2 trailers; Connect and gRPC-Web encode trailers in the body.
Trait Implementations§
impl Copy for Protocol
impl Eq for Protocol
impl StructuralPartialEq for Protocol
Auto Trait Implementations§
impl Freeze for Protocol
impl RefUnwindSafe for Protocol
impl Send for Protocol
impl Sync for Protocol
impl Unpin for Protocol
impl UnsafeUnpin for Protocol
impl UnwindSafe for Protocol
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.