pub struct Forwarded { /* private fields */ }
Expand description
Forwarding information stored as a chain.
This extension (which can be stored and modified via the Context
)
allows to keep track of the forward information. E.g. what was the original
host used by the user, by which proxy it was forwarded, what was the intended
protocol (e.g. https), etc…
Implementations§
Source§impl Forwarded
impl Forwarded
Sourcepub const fn new(element: ForwardedElement) -> Forwarded
pub const fn new(element: ForwardedElement) -> Forwarded
Create a new Forwarded
extension for the given ForwardedElement
as the client Element (the first element).
Sourcepub fn client_host(&self) -> Option<&ForwardedAuthority>
pub fn client_host(&self) -> Option<&ForwardedAuthority>
Return the client host of this Forwarded
context,
if there is one defined.
It is assumed that only the first element can be described as client information.
Sourcepub fn client_socket_addr(&self) -> Option<SocketAddr>
pub fn client_socket_addr(&self) -> Option<SocketAddr>
Return the client SocketAddr
of this Forwarded
context,
if both an Ip and a port are defined.
You can try to fallback to Self::client_ip
,
in case this method returns None
.
Sourcepub fn client_port(&self) -> Option<u16>
pub fn client_port(&self) -> Option<u16>
Return the client port of this Forwarded
context,
if there is one defined.
Sourcepub fn client_ip(&self) -> Option<IpAddr>
pub fn client_ip(&self) -> Option<IpAddr>
Return the client Ip of this Forwarded
context,
if there is one defined.
This method may return None because there is no forwarded “for” information for the client element or because the IP is obfuscated.
It is assumed that only the first element can be described as client information.
Sourcepub fn client_proto(&self) -> Option<ForwardedProtocol>
pub fn client_proto(&self) -> Option<ForwardedProtocol>
Return the client protocol of this Forwarded
context,
if there is one defined.
Sourcepub fn client_version(&self) -> Option<ForwardedVersion>
pub fn client_version(&self) -> Option<ForwardedVersion>
Return the client protocol version of this Forwarded
context,
if there is one defined.
Sourcepub fn append(&mut self, element: ForwardedElement) -> &mut Forwarded
pub fn append(&mut self, element: ForwardedElement) -> &mut Forwarded
Append a ForwardedElement
to this Forwarded
context.
Sourcepub fn extend(
&mut self,
elements: impl IntoIterator<Item = ForwardedElement>,
) -> &mut Forwarded
pub fn extend( &mut self, elements: impl IntoIterator<Item = ForwardedElement>, ) -> &mut Forwarded
Extend this Forwarded
context with the given ForwardedElement
s.
Sourcepub fn iter(&self) -> impl Iterator<Item = &ForwardedElement>
pub fn iter(&self) -> impl Iterator<Item = &ForwardedElement>
Iterate over the ForwardedElement
s in this Forwarded
context.
Trait Implementations§
Source§impl ForwardHeader for Forwarded
impl ForwardHeader for Forwarded
Source§fn try_from_forwarded<'a, I>(input: I) -> Option<Self>where
I: IntoIterator<Item = &'a ForwardedElement>,
fn try_from_forwarded<'a, I>(input: I) -> Option<Self>where
I: IntoIterator<Item = &'a ForwardedElement>,
ForwardedElement
into the header. Read moreSource§impl From<ForwardedElement> for Forwarded
impl From<ForwardedElement> for Forwarded
Source§fn from(value: ForwardedElement) -> Forwarded
fn from(value: ForwardedElement) -> Forwarded
Source§impl Header for Forwarded
Available on crate feature http
only.
impl Header for Forwarded
http
only.Source§impl IntoIterator for Forwarded
impl IntoIterator for Forwarded
Source§type Item = ForwardedElement
type Item = ForwardedElement
Source§type IntoIter = Chain<Once<ForwardedElement>, IntoIter<ForwardedElement>>
type IntoIter = Chain<Once<ForwardedElement>, IntoIter<ForwardedElement>>
Source§impl TryFrom<&HeaderValue> for Forwarded
Available on crate feature http
only.
impl TryFrom<&HeaderValue> for Forwarded
http
only.Source§type Error = OpaqueError
type Error = OpaqueError
Source§fn try_from(
header: &HeaderValue,
) -> Result<Forwarded, <Forwarded as TryFrom<&HeaderValue>>::Error>
fn try_from( header: &HeaderValue, ) -> Result<Forwarded, <Forwarded as TryFrom<&HeaderValue>>::Error>
Source§impl TryFrom<HeaderValue> for Forwarded
Available on crate feature http
only.
impl TryFrom<HeaderValue> for Forwarded
http
only.Source§type Error = OpaqueError
type Error = OpaqueError
Source§fn try_from(
header: HeaderValue,
) -> Result<Forwarded, <Forwarded as TryFrom<HeaderValue>>::Error>
fn try_from( header: HeaderValue, ) -> Result<Forwarded, <Forwarded as TryFrom<HeaderValue>>::Error>
impl Eq for Forwarded
impl StructuralPartialEq for Forwarded
Auto Trait Implementations§
impl Freeze for Forwarded
impl RefUnwindSafe for Forwarded
impl Send for Forwarded
impl Sync for Forwarded
impl Unpin for Forwarded
impl UnwindSafe for Forwarded
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<H> HeaderExt for Hwhere
H: Header + Sealed,
impl<H> HeaderExt for Hwhere
H: Header + Sealed,
Source§fn encode_to_value(&self) -> HeaderValue
fn encode_to_value(&self) -> HeaderValue
Header
to HeaderValue
.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>
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.