pub struct Connection(/* private fields */);Expand description
Connection header, defined in
RFC7230
The Connection header field allows the sender to indicate desired
control options for the current connection. In order to avoid
confusing downstream recipients, a proxy or gateway MUST remove or
replace any received connection options before forwarding the
message.
§ABNF
Connection = 1#connection-option
connection-option = token
# Example values
* `close`
* `keep-alive`
* `upgrade`
* `keep-alive, upgrade`§Examples
use rama_http_headers::Connection;
let keep_alive = Connection::keep_alive();Implementations§
Source§impl Connection
impl Connection
pub fn iter_headers(&self) -> impl Iterator<Item = &HeaderName>
Source§impl Connection
impl Connection
Sourcepub fn open(headers: NonEmptyVec<HeaderName>) -> Self
pub fn open(headers: NonEmptyVec<HeaderName>) -> Self
A constructor to easily create a Connection header,
for the given header names.
Sourcepub fn is_close(&self) -> bool
pub fn is_close(&self) -> bool
Returns true if this Connection header contains close.
Sourcepub fn keep_alive() -> Self
pub fn keep_alive() -> Self
A constructor to easily create a Connection: keep-alive header.
Sourcepub fn contains_header(&self, name: impl PartialEq<HeaderName>) -> bool
pub fn contains_header(&self, name: impl PartialEq<HeaderName>) -> bool
Returns true if this Connection header contains the given header.
§Example
use rama_http_types::header::UPGRADE;
use rama_http_headers::Connection;
let conn = Connection::keep_alive();
assert!(!conn.contains_header(UPGRADE));
assert!(conn.contains_header("keep-alive"));
assert!(conn.contains_header("Keep-Alive"));Sourcepub fn contains_upgrade(&self) -> bool
pub fn contains_upgrade(&self) -> bool
Returns true if this Connection header contains Upgrade.
§Example
use rama_http_headers::Connection;
assert!(!Connection::keep_alive().contains_upgrade());
assert!(Connection::upgrade().contains_upgrade());Sourcepub fn contains_keep_alive(&self) -> bool
pub fn contains_keep_alive(&self) -> bool
Returns true if this Connection header contains Keep-Alive.
§Example
use rama_http_headers::Connection;
assert!(Connection::keep_alive().contains_keep_alive());
assert!(!Connection::upgrade().contains_keep_alive());Trait Implementations§
Source§impl Clone for Connection
impl Clone for Connection
Source§fn clone(&self) -> Connection
fn clone(&self) -> Connection
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Connection
impl Debug for Connection
Source§impl HeaderDecode for Connection
impl HeaderDecode for Connection
Source§fn decode<'i, I>(values: &mut I) -> Result<Self, Error>where
I: Iterator<Item = &'i HeaderValue>,
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>where
I: Iterator<Item = &'i HeaderValue>,
Decode this type from an iterator of
HeaderValues.Source§impl HeaderEncode for Connection
impl HeaderEncode for Connection
Source§fn encode<E: Extend<HeaderValue>>(&self, values: &mut E)
fn encode<E: Extend<HeaderValue>>(&self, values: &mut E)
Encode this type to a
HeaderValue, and add it to a container
which has HeaderValue type as each element. Read moreSource§fn encode_to_value(&self) -> Option<HeaderValue>
fn encode_to_value(&self) -> Option<HeaderValue>
Encode this header to
HeaderValue. Read moreSource§impl TypedHeader for Connection
impl TypedHeader for Connection
Source§fn name() -> &'static HeaderName
fn name() -> &'static HeaderName
The name of this header.
Auto Trait Implementations§
impl !Freeze for Connection
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
impl UnwindSafe for Connection
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
Mutably borrows from an owned value. Read more
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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