Struct Protocol

pub struct Protocol { /* private fields */ }

Extension type representing the :protocol pseudo-header in HTTP/2.

The Protocol extension allows access to the value of the :protocol pseudo-header used by the Extended CONNECT Protocol. This extension is only sent on HTTP/2 CONNECT requests, most commonly with the value websocket.

Example

use hyper::ext::Protocol;
use http::{Request, Method, Version};

let mut req = Request::new(());
*req.method_mut() = Method::CONNECT;
*req.version_mut() = Version::HTTP_2;
req.extensions_mut().insert(Protocol::from_static("websocket"));
// Now the request will include the `:protocol` pseudo-header with value "websocket"

Implementations

impl Protocol

const fn from_static(value: &'static str) -> Self

Converts a static string to a protocol name.

fn as_str(&self) -> &str

Returns a str representation of the header.

Trait Implementations

impl AsRef<[u8]> for Protocol

fn as_ref(&self) -> &[u8]

impl Clone for Protocol

fn clone(&self) -> Protocol

impl Debug for Protocol

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Eq for Protocol

impl PartialEq for Protocol

fn eq(&self, other: &Protocol) -> bool

impl StructuralPartialEq for Protocol

impl<'a> From<&'a str> for Protocol

fn from(value: &'a str) -> Self

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<Q, K> Equivalent<K> for Protocol where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

fn equivalent(&self, key: &K) -> bool

impl<Q, K> Equivalent<K> for Protocol where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

fn equivalent(&self, key: &K) -> bool

impl<T> Any for Protocol where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Protocol where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Protocol where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Protocol where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Protocol

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for Protocol

impl<T> ToOwned for Protocol where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> WithSubscriber for Protocol

impl<T, U> Into<U> for Protocol where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Protocol where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Protocol where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>