pub struct Protocol(/* private fields */);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§
Source§impl Protocol
impl Protocol
Sourcepub const HTTP_SCHEME: &str = "http"
pub const HTTP_SCHEME: &str = "http"
HTTP protocol scheme
Sourcepub const HTTP_DEFAULT_PORT: u16 = 80
pub const HTTP_DEFAULT_PORT: u16 = 80
HTTP protocol default port
Sourcepub const HTTP_ALT_PORT: u16 = 8080
pub const HTTP_ALT_PORT: u16 = 8080
Common alternate HTTP protocol port.
Sourcepub 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.
Sourcepub const HTTPS_SCHEME: &str = "https"
pub const HTTPS_SCHEME: &str = "https"
HTTPS protocol scheme
Sourcepub const HTTPS_DEFAULT_PORT: u16 = 443
pub const HTTPS_DEFAULT_PORT: u16 = 443
HTTPS protocol default port
Sourcepub const HTTPS_ALT_PORT: u16 = 8443
pub const HTTPS_ALT_PORT: u16 = 8443
Common alternate HTTPS protocol port.
Sourcepub const WS_DEFAULT_PORT: u16 = Self::HTTP_DEFAULT_PORT
pub const WS_DEFAULT_PORT: u16 = Self::HTTP_DEFAULT_PORT
WS protocol default port
Sourcepub const WSS_SCHEME: &str = "wss"
pub const WSS_SCHEME: &str = "wss"
WSS protocol scheme
Sourcepub const WSS_DEFAULT_PORT: u16 = Self::HTTPS_DEFAULT_PORT
pub const WSS_DEFAULT_PORT: u16 = Self::HTTPS_DEFAULT_PORT
WSS protocol default port
Sourcepub const SOCKS5_SCHEME: &str = "socks5"
pub const SOCKS5_SCHEME: &str = "socks5"
SOCKS5 protocol scheme
Sourcepub const SOCKS5_DEFAULT_PORT: u16 = 1080
pub const SOCKS5_DEFAULT_PORT: u16 = 1080
SOCKS5 protocol default port
Sourcepub const SOCKS5H_SCHEME: &str = "socks5h"
pub const SOCKS5H_SCHEME: &str = "socks5h"
SOCKS5H protocol scheme
Sourcepub const SOCKS5H_DEFAULT_PORT: u16 = Self::SOCKS5_DEFAULT_PORT
pub const SOCKS5H_DEFAULT_PORT: u16 = Self::SOCKS5_DEFAULT_PORT
SOCKS5H protocol default port
Sourcepub const FILE_SCHEME: &str = "file"
pub const FILE_SCHEME: &str = "file"
FILE protocol scheme. RFC 8089 — file:///path/to/x.
Sourcepub const FILE: Self
pub const FILE: Self
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.
Sourcepub const DATA_SCHEME: &str = "data"
pub const DATA_SCHEME: &str = "data"
DATA protocol scheme. RFC 2397 — data:[<mediatype>][;base64],<data>.
Sourcepub const DATA: Self
pub const DATA: Self
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.
Sourcepub const fn from_static(s: &'static str) -> Self
pub const fn from_static(s: &'static str) -> Self
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.
Sourcepub 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.
Sourcepub 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.
Sourcepub fn canonicalize(self) -> Self
pub fn canonicalize(self) -> Self
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
Source§impl From<ForwardedProtocol> for Protocol
impl From<ForwardedProtocol> for Protocol
Source§fn from(p: ForwardedProtocol) -> Self
fn from(p: ForwardedProtocol) -> Self
impl NetExtension for Protocol
Source§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,
Source§impl PartialOrd for Protocol
impl PartialOrd for Protocol
impl StructuralPartialEq for Protocol
Source§impl TryFrom<&Protocol> for ForwardedProtocol
impl TryFrom<&Protocol> for ForwardedProtocol
Source§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§
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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<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> Pointable for T
impl<T> Pointable for T
Source§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
Source§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,
Source§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writerSource§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writerSource§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writerSource§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writerSource§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer