Struct Protocol
pub struct Protocol(/* private fields */);net only.Expand description
Web protocols that are relevant to Rama.
Please file an issue or open a PR if you need support for more protocols. When doing so please provide sufficient motivation and ensure it has no unintended consequences.
Implementations§
§impl Protocol
impl Protocol
pub const HTTP_SCHEME: &'static str = "http"
pub const HTTP_SCHEME: &'static str = "http"
HTTP protocol scheme
pub const HTTP_DEFAULT_PORT: u16 = 80
pub const HTTP_DEFAULT_PORT: u16 = 80
HTTP protocol default port
pub const HTTP_ALT_PORT: u16 = 8080
pub const HTTP_ALT_PORT: u16 = 8080
Common alternate HTTP protocol port.
pub const HTTP_PROXY_DEFAULT_PORT: u16 = 1080
pub const HTTP_PROXY_DEFAULT_PORT: u16 = 1080
Common default port for an HTTP proxy address without an explicit port.
This follows the long-standing curl proxy-address convention. It is
distinct from HTTP_DEFAULT_PORT, which is
the default port for an HTTP origin server.
pub const HTTPS_SCHEME: &'static str = "https"
pub const HTTPS_SCHEME: &'static str = "https"
HTTPS protocol scheme
pub const HTTPS_DEFAULT_PORT: u16 = 443
pub const HTTPS_DEFAULT_PORT: u16 = 443
HTTPS protocol default port
pub const HTTPS_ALT_PORT: u16 = 8443
pub const HTTPS_ALT_PORT: u16 = 8443
Common alternate HTTPS protocol port.
pub const WS_DEFAULT_PORT: u16 = Self::HTTP_DEFAULT_PORT
pub const WS_DEFAULT_PORT: u16 = Self::HTTP_DEFAULT_PORT
WS protocol default port
pub const WSS_SCHEME: &'static str = "wss"
pub const WSS_SCHEME: &'static str = "wss"
WSS protocol scheme
pub const WSS_DEFAULT_PORT: u16 = Self::HTTPS_DEFAULT_PORT
pub const WSS_DEFAULT_PORT: u16 = Self::HTTPS_DEFAULT_PORT
WSS protocol default port
pub const SOCKS5_SCHEME: &'static str = "socks5"
pub const SOCKS5_SCHEME: &'static str = "socks5"
SOCKS5 protocol scheme
pub const SOCKS5_DEFAULT_PORT: u16 = 1080
pub const SOCKS5_DEFAULT_PORT: u16 = 1080
SOCKS5 protocol default port
pub const SOCKS5H_SCHEME: &'static str = "socks5h"
pub const SOCKS5H_SCHEME: &'static str = "socks5h"
SOCKS5H protocol scheme
pub const SOCKS5H_DEFAULT_PORT: u16 = Self::SOCKS5_DEFAULT_PORT
pub const SOCKS5H_DEFAULT_PORT: u16 = Self::SOCKS5_DEFAULT_PORT
SOCKS5H protocol default port
pub const FILE_SCHEME: &'static str = "file"
pub const FILE_SCHEME: &'static str = "file"
FILE protocol scheme. RFC 8089 — file:///path/to/x.
pub const FILE: Protocol
pub const FILE: Protocol
The file protocol. Local-filesystem URI scheme: the URI
references a path on the host running the URI consumer.
Consumers (CLI tools, file fetchers) open the path directly
rather than dialing a network endpoint.
pub const DATA_SCHEME: &'static str = "data"
pub const DATA_SCHEME: &'static str = "data"
DATA protocol scheme. RFC 2397 — data:[<mediatype>][;base64],<data>.
pub const DATA: Protocol
pub const DATA: Protocol
The data protocol. Self-contained URI scheme: the URI itself
carries the payload, which consumers decode in place rather
than dialing a network endpoint or opening a file.
pub const fn from_static(s: &'static str) -> Protocol
pub const fn from_static(s: &'static str) -> Protocol
Creates a Protocol from a str a compile time.
This function requires the static string to be a valid protocol.
It is intended to be used to facilitate the compile-time creation of custom Protocols, as known protocols are easier created by using the desired variant directly.
§Panics
This function panics at compile time when the static string is not a valid protocol.
pub fn default_port(&self) -> Option<u16>
pub fn default_port(&self) -> Option<u16>
Returns the default port for this Protocol.
Registered defaults: http=80, https=443, ws=80, wss=443,
socks5=1080, socks5h=1080. Other schemes (ftp:21, ssh:22,
ldap:389, …) return None — Protocol’s scope is the
web-protocol set rama actively models.
crate::uri::Uri::canonicalize only drops ports that match a
registered default, so ftp://host:21/ keeps its :21. This
diverges from WHATWG-URL (which strips ftp:21).
The set of supported protocols grows with the needs that justify them.
pub fn proxy_default_port(&self) -> Option<u16>
pub fn proxy_default_port(&self) -> Option<u16>
Returns the default port when this protocol is used to reach a proxy.
An HTTP proxy URL follows the long-standing curl convention of port 1080 when its authority omits a port. HTTPS, SOCKS5, and SOCKS5H use their protocol defaults. Other protocols do not have an implicit proxy port.
pub fn canonicalize(self) -> Protocol
pub fn canonicalize(self) -> Protocol
Return the RFC 3986 canonical presentation of this scheme.
Known protocols are stored canonically already. A custom scheme is ASCII-lowercased, allocating only when its presentation contains an uppercase letter.
Trait Implementations§
impl Eq for Protocol
impl Extension for Protocol
§impl From<ForwardedProtocol> for Protocol
impl From<ForwardedProtocol> for Protocol
§fn from(p: ForwardedProtocol) -> Protocol
fn from(p: ForwardedProtocol) -> Protocol
§impl From<Protocol> for SourceExpression
impl From<Protocol> for SourceExpression
§fn from(p: Protocol) -> SourceExpression
fn from(p: Protocol) -> SourceExpression
impl NetExtension for Protocol
§impl Ord for Protocol
impl Ord for Protocol
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 Protocol
impl PartialOrd for Protocol
impl StructuralPartialEq for Protocol
§impl TryFrom<&Protocol> for ForwardedProtocol
impl TryFrom<&Protocol> for ForwardedProtocol
§impl TryFrom<Protocol> for ForwardedProtocol
impl TryFrom<Protocol> for ForwardedProtocol
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<'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
§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<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.