Struct UserInfo
pub struct UserInfo { /* private fields */ }net only.Expand description
Raw RFC 3986 userinfo bytes. Cheap to clone.
§Logging safety
The Debug impl redacts the password portion (anything
after the first :) as "***", matching Basic’s logging behaviour.
This is the safe default for tracing spans and log lines, where a raw
Debug-print of a Uri would otherwise leak
credentials into observability sinks. The user portion is rendered raw;
pct-encoded bytes are not decoded for the Debug view.
Implementations§
§impl UserInfo
impl UserInfo
pub const fn from_static(s: &'static str) -> UserInfo
pub const fn from_static(s: &'static str) -> UserInfo
Construct from a compile-time string. Zero-allocation.
Panics at compile time if s contains a byte outside the
RFC 3986 §3.2.1 userinfo grammar (unreserved / pct-encoded / sub-delims / ":"). This matches the URI parser’s strict-mode
validation: byte sets stay single-sourced, and typed construction
can never produce a UserInfo that the parser would reject.
Naming: from_static matches the Uri::from_static /
Domain::from_static precedent across the rest of the crate.
pub fn view(&self) -> UserInfoRef<'_>
pub fn view(&self) -> UserInfoRef<'_>
Borrowed view. Named view (not as_ref) so it doesn’t shadow
the std AsRef trait — see the type-level docs.
pub fn split_user_password(&self) -> (&[u8], Option<&[u8]>)
pub fn split_user_password(&self) -> (&[u8], Option<&[u8]>)
Split on the first :. Returns (user_bytes, password_bytes)
where the password is None if no : is present.
Bytes are raw — not percent-decoded. Use
crate::uri::util::percent_encoding to decode if needed.
pub fn as_decoded_str(&self) -> Cow<'_, str>
pub fn as_decoded_str(&self) -> Cow<'_, str>
Percent-decoded view of the full userinfo. Cow::Borrowed when no
%XX escapes are present; UTF-8 errors fall back to U+FFFD.
Lossy for re-splitting: a %3A in the user part decodes to a
literal :. Use UserInfo::username_decoded /
UserInfo::password_decoded to decode the components separately.
pub fn username_decoded(&self) -> Cow<'_, str>
pub fn username_decoded(&self) -> Cow<'_, str>
Percent-decoded user component (everything before the first raw :).
pub fn password_decoded(&self) -> Option<Cow<'_, str>>
pub fn password_decoded(&self) -> Option<Cow<'_, str>>
Percent-decoded password component (everything after the first raw
:), or None if no : is present.
Trait Implementations§
impl Eq for UserInfo
§impl<'a> From<&'a UserInfo> for UserInfoRef<'a>
impl<'a> From<&'a UserInfo> for UserInfoRef<'a>
§fn from(u: &'a UserInfo) -> UserInfoRef<'a>
fn from(u: &'a UserInfo) -> UserInfoRef<'a>
§impl From<Basic> for UserInfo
Construct a UserInfo from a Basic credential by
percent-encoding each component into the RFC 3986 §3.2.1 userinfo
wire form. The username escapes : (so the first literal : is
unambiguously the user/password separator); the password keeps :
literal. @, space, and every other non-userinfo byte become %XX,
so the result re-parses cleanly through UserInfo::try_from and
decodes back to the original credential via UserInfo::to_basic.
impl From<Basic> for UserInfo
Construct a UserInfo from a Basic credential by
percent-encoding each component into the RFC 3986 §3.2.1 userinfo
wire form. The username escapes : (so the first literal : is
unambiguously the user/password separator); the password keeps :
literal. @, space, and every other non-userinfo byte become %XX,
so the result re-parses cleanly through UserInfo::try_from and
decodes back to the original credential via UserInfo::to_basic.
§Round-trip invariant
Encoding always yields grammar-valid userinfo. The Basic →
UserInfo → UserInfo::try_from round-trip holds for exactly the
Basic values whose components are free of control bytes
(0x00–0x1F / 0x7F): any control byte encodes to a %XX escape
that strict parsing then refuses as a pct-decoded-control smuggling
vector. Basic::try_from pre-rejects \r / \n / NUL, but the
typed constructors (Basic::new, the with_/set_ setters,
clone_with_*) do not validate, so any control byte can reach this
obscure residual regardless of which entry point built the Basic.
§impl Ord for UserInfo
impl Ord for UserInfo
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialOrd for UserInfo
impl PartialOrd for UserInfo
impl StructuralPartialEq for UserInfo
§impl TryFrom<&UserInfo> for Basic
impl TryFrom<&UserInfo> for Basic
§impl TryFrom<&str> for UserInfo
impl TryFrom<&str> for UserInfo
§fn try_from(s: &str) -> Result<UserInfo, <UserInfo as TryFrom<&str>>::Error>
fn try_from(s: &str) -> Result<UserInfo, <UserInfo as TryFrom<&str>>::Error>
Validate s against the RFC 3986 §3.2.1 userinfo grammar —
same byte set the URI parser uses in strict mode. Rejects:
- Control bytes anywhere.
- Raw
@(must be percent-encoded as%40). - Raw space, brackets, gen-delims, and other non-userinfo bytes.
- Malformed pct-escapes (
%Xtruncated,%XYnon-hex). - Pct-decoded control bytes (smuggling vector).
Without this guard, Uri::set_authority(authority_with_loose_userinfo)
could embed bytes the parser would otherwise reject — producing
URIs that round-trip into malformed wire form.
Auto Trait Implementations§
impl !Freeze for UserInfo
impl RefUnwindSafe for UserInfo
impl Send for UserInfo
impl Sync for UserInfo
impl Unpin for UserInfo
impl UnsafeUnpin for UserInfo
impl UnwindSafe for UserInfo
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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<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§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.
§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writer§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writer§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writer§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writer§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer