Struct Authority
pub struct Authority {
pub user_info: Option<UserInfo>,
pub address: HostWithOptPort,
}net only.Expand description
A Host with optionally a port and/or user-info (UserInfo).
user_info is the raw RFC 3986 §3.2.1 view (opaque bytes). For HTTP
Basic-Auth interop call UserInfo::to_basic on it.
Planned migration: in a follow-up PR after the URI work, when
rama’s Basic is relaxed to allow empty
usernames (per RFC 7617 §2), the intent is to replace
Option<UserInfo> here with Option<Basic>. See the
user_info module docs for the rationale.
§Examples
- example.com
- 127.0.0.1
- example.com:80
- 127.0.0.1:80
- joe@example.com:80
- joe:secret@example.com
Fields§
§user_info: Option<UserInfo>§address: HostWithOptPortImplementations§
§impl Authority
impl Authority
pub const fn new(addr: HostWithOptPort) -> Authority
pub const fn new(addr: HostWithOptPort) -> Authority
Creates a new Authority from a HostWithOptPort.
pub fn new_with_user_info(
addr: HostWithOptPort,
user_info: UserInfo,
) -> Authority
pub fn new_with_user_info( addr: HostWithOptPort, user_info: UserInfo, ) -> Authority
Creates a new Authority from a HostWithOptPort and user-info
(UserInfo).
Not const fn — UserInfo wraps Bytes which has no const
constructor; use the builder (Self::with_user_info) plus
UserInfo::from_static for the const-friendly path.
pub const fn from_static(s: &'static str) -> Authority
pub const fn from_static(s: &'static str) -> Authority
Compile-time constructor for a domain-only Authority
(no user-info, no explicit port). Panics at compile time when
s isn’t a valid domain.
pub const fn local_ipv4() -> Authority
pub const fn local_ipv4() -> Authority
pub const fn local_ipv4_with_port(port: u16) -> Authority
pub const fn local_ipv4_with_port(port: u16) -> Authority
pub const fn local_ipv6() -> Authority
pub const fn local_ipv6() -> Authority
creates a new local ipv6 Authority without a port.
§Example
IPv6 addresses always render with […] brackets even with no
port — see HostWithOptPort’s Display impl for the
rationale.
use rama_net::address::Authority;
let addr = Authority::local_ipv6();
assert_eq!("[::1]", addr.to_string());pub const fn local_ipv6_with_port(port: u16) -> Authority
pub const fn local_ipv6_with_port(port: u16) -> Authority
pub const fn default_ipv4() -> Authority
pub const fn default_ipv4() -> Authority
pub const fn default_ipv4_with_port(port: u16) -> Authority
pub const fn default_ipv4_with_port(port: u16) -> Authority
pub const fn default_ipv6() -> Authority
pub const fn default_ipv6() -> Authority
creates a new default ipv6 Authority without a port.
IPv6 addresses always render with […] brackets even with no
port — see HostWithOptPort’s Display impl for the
rationale.
§Example
use rama_net::address::Authority;
let addr = Authority::default_ipv6();
assert_eq!("[::]", addr.to_string());pub const fn default_ipv6_with_port(port: u16) -> Authority
pub const fn default_ipv6_with_port(port: u16) -> Authority
pub const fn broadcast_ipv4() -> Authority
pub const fn broadcast_ipv4() -> Authority
pub const fn broadcast_ipv4_with_port(port: u16) -> Authority
pub const fn broadcast_ipv4_with_port(port: u16) -> Authority
pub const fn example_domain() -> Authority
pub const fn example_domain() -> Authority
Creates a new example domain Authority without a port.
pub const fn example_domain_http() -> Authority
pub const fn example_domain_http() -> Authority
Creates a new example domain HostWithOptPort for the http default port.
pub const fn example_domain_https() -> Authority
pub const fn example_domain_https() -> Authority
Creates a new example domain HostWithOptPort for the https default port.
pub const fn example_domain_with_port(port: u16) -> Authority
pub const fn example_domain_with_port(port: u16) -> Authority
Creates a new example domain HostWithOptPort for the given port.
pub const fn localhost_domain() -> Authority
pub const fn localhost_domain() -> Authority
Creates a new localhost domain HostWithOptPort without a port.
pub const fn localhost_domain_http() -> Authority
pub const fn localhost_domain_http() -> Authority
Creates a new localhost domain HostWithOptPort for the http default port.
pub const fn localhost_domain_https() -> Authority
pub const fn localhost_domain_https() -> Authority
Creates a new localhost domain HostWithOptPort for the https default port.
pub const fn localhost_domain_with_port(port: u16) -> Authority
pub const fn localhost_domain_with_port(port: u16) -> Authority
Creates a new localhost domain HostWithOptPort for the given port.
pub fn with_host(self, host: impl Into<Host>) -> Authority
pub fn with_host(self, host: impl Into<Host>) -> Authority
Set Host of Authority. Accepts any Into<Host> —
Domain, IpAddr, and so on.
pub fn set_host(&mut self, host: impl Into<Host>) -> &mut Authority
pub fn set_host(&mut self, host: impl Into<Host>) -> &mut Authority
Set Host of Authority. Accepts any Into<Host> —
Domain, IpAddr, and so on.
pub fn with_port(self, port: impl Into<OptPort>) -> Authority
pub fn with_port(self, port: impl Into<OptPort>) -> Authority
Set the port of Authority. Accepts u16, OptPort, or
Option<u16> via Into<OptPort>. Pass OptPort::Unset
to clear.
pub fn set_port(&mut self, port: impl Into<OptPort>) -> &mut Authority
pub fn set_port(&mut self, port: impl Into<OptPort>) -> &mut Authority
Set the port of Authority. Accepts u16, OptPort, or
Option<u16> via Into<OptPort>. Pass OptPort::Unset
to clear.
pub const fn port_u16(&self) -> Option<u16>
pub const fn port_u16(&self) -> Option<u16>
Relaxed view of the port — Set(n) → Some(n), everything else
None. Use when the Unset vs Empty distinction doesn’t matter.
pub fn maybe_with_user_info(self, user_info: Option<UserInfo>) -> Authority
pub fn maybe_with_user_info(self, user_info: Option<UserInfo>) -> Authority
pub fn maybe_set_user_info(
&mut self,
user_info: Option<UserInfo>,
) -> &mut Authority
pub fn maybe_set_user_info( &mut self, user_info: Option<UserInfo>, ) -> &mut Authority
pub fn with_user_info(self, user_info: UserInfo) -> Authority
pub fn with_user_info(self, user_info: UserInfo) -> Authority
pub fn set_user_info(&mut self, user_info: UserInfo) -> &mut Authority
pub fn set_user_info(&mut self, user_info: UserInfo) -> &mut Authority
pub fn without_user_info(self) -> Authority
pub fn without_user_info(self) -> Authority
pub fn unset_user_info(&mut self) -> &mut Authority
pub fn unset_user_info(&mut self) -> &mut Authority
pub fn view(&self) -> AuthorityRef<'_>
pub fn view(&self) -> AuthorityRef<'_>
Borrowed view.
Trait Implementations§
§impl<'de> Deserialize<'de> for Authority
impl<'de> Deserialize<'de> for Authority
§fn deserialize<D>(
deserializer: D,
) -> Result<Authority, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Authority, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl<'a> From<&'a Authority> for AuthorityRef<'a>
impl<'a> From<&'a Authority> for AuthorityRef<'a>
§fn from(a: &'a Authority) -> AuthorityRef<'a>
fn from(a: &'a Authority) -> AuthorityRef<'a>
§impl From<&SocketAddr> for Authority
impl From<&SocketAddr> for Authority
§fn from(addr: &SocketAddr) -> Authority
fn from(addr: &SocketAddr) -> Authority
§impl From<&SocketAddress> for Authority
impl From<&SocketAddress> for Authority
§fn from(addr: &SocketAddress) -> Authority
fn from(addr: &SocketAddress) -> Authority
§impl From<Authority> for HostWithOptPort
impl From<Authority> for HostWithOptPort
§fn from(addr: Authority) -> HostWithOptPort
fn from(addr: Authority) -> HostWithOptPort
§impl From<DomainAddress> for Authority
impl From<DomainAddress> for Authority
§fn from(addr: DomainAddress) -> Authority
fn from(addr: DomainAddress) -> Authority
§impl From<HostWithOptPort> for Authority
impl From<HostWithOptPort> for Authority
§fn from(addr: HostWithOptPort) -> Authority
fn from(addr: HostWithOptPort) -> Authority
§impl From<HostWithPort> for Authority
impl From<HostWithPort> for Authority
§fn from(addr: HostWithPort) -> Authority
fn from(addr: HostWithPort) -> Authority
§impl From<SocketAddr> for Authority
impl From<SocketAddr> for Authority
§fn from(addr: SocketAddr) -> Authority
fn from(addr: SocketAddr) -> Authority
§impl From<SocketAddress> for Authority
impl From<SocketAddress> for Authority
§fn from(addr: SocketAddress) -> Authority
fn from(addr: SocketAddress) -> Authority
§impl IntoCanonicalIpAddr for Authority
impl IntoCanonicalIpAddr for Authority
fn into_canonical_ip_addr(self) -> Authority
§impl Serialize for Authority
impl Serialize for Authority
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for Authority
impl StructuralPartialEq for Authority
Auto Trait Implementations§
impl !Freeze for Authority
impl RefUnwindSafe for Authority
impl Send for Authority
impl Sync for Authority
impl Unpin for Authority
impl UnsafeUnpin for Authority
impl UnwindSafe for Authority
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
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
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> 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