Struct Protocol
pub struct Protocol { /* private fields */ }http-backend and http and std only.Expand description
The Protocol extension carries the value of the :protocol pseudo-header used by the
Extended CONNECT Protocol.
It is shared by HTTP/2 (RFC 8441) and HTTP/3 (RFC 9220): both carry the same :protocol
pseudo-header, most commonly with the value websocket.
The value is a validated, non-empty HTTP token (RFC 9110 §5.6.2). Every construction path
enforces that invariant, so a Protocol can never hold an empty or non-token value that
would be illegal on the wire.
§Example
use rama_core::extensions::ExtensionsRef;
use rama_http_types::proto::h2::ext::Protocol;
use rama_http_types::{Request, Method, Version};
let mut req = Request::new(());
*req.method_mut() = Method::CONNECT;
*req.version_mut() = Version::HTTP_2;
req.extensions().insert(Protocol::WEBSOCKET);
// Now the request will include the `:protocol` pseudo-header with value "websocket"Implementations§
§impl Protocol
impl Protocol
pub const WEBSOCKET: Protocol
pub const WEBSOCKET: Protocol
websocket, the token registered by RFC 8441 for the WebSocket Protocol.
It is used for Extended CONNECT over both HTTP/2 (RFC 8441) and HTTP/3 (RFC 9220).
pub const fn from_static(value: &'static str) -> Protocol
pub const fn from_static(value: &'static str) -> Protocol
Converts a static string to a protocol name.
§Panics
Panics if value is not a non-empty HTTP token. Because a :protocol value that is not
a token cannot be sent on the wire, an invalid literal is a programming error rather than
a runtime condition.
pub fn try_from_bytes(bytes: Bytes) -> Result<Protocol, InvalidProtocol>
pub fn try_from_bytes(bytes: Bytes) -> Result<Protocol, InvalidProtocol>
Parses a :protocol value from raw wire bytes, validating that it is a non-empty token.
Trait Implementations§
impl Eq for Protocol
impl Extension for Protocol
impl HttpExtension 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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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> ⓘ
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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more