Skip to main content

CanonicalOrigin

Struct CanonicalOrigin 

Source
pub struct CanonicalOrigin { /* private fields */ }
Expand description

A node’s canonical origin: the one origin every signed tenant URL names.

The gate refuses a signed URL that does not start with exactly this text, and a Host other than its authority, so the client keeps the origin in the single spelling the node’s configuration allows: http:// or https://, a lowercase DNS name, IPv4 literal or bracketed IPv6 literal in its RFC 5952 form, an optional port that is not the scheme’s default, and no user information, path, query or fragment. A single trailing / is accepted and dropped.

§Examples

use stratum_node_cli::CanonicalOrigin;

let origin: CanonicalOrigin = "https://stratum.visionclaw.pro/".parse()?;
assert_eq!(origin.as_str(), "https://stratum.visionclaw.pro");
assert_eq!(origin.authority(), "stratum.visionclaw.pro");
assert_eq!(origin.url("/pods/"), "https://stratum.visionclaw.pro/pods/");

assert!("https://Stratum.example".parse::<CanonicalOrigin>().is_err());
assert!("https://stratum.example:443".parse::<CanonicalOrigin>().is_err());
assert!("https://stratum.example/pods".parse::<CanonicalOrigin>().is_err());

Implementations§

Source§

impl CanonicalOrigin

Source

pub fn scheme(&self) -> Scheme

Returns the scheme.

Source

pub fn host(&self) -> &str

Returns the host as written: a DNS name, an IPv4 literal or a bracketed IPv6 literal.

Source

pub fn port(&self) -> u16

Returns the port, the scheme’s default when the origin names none.

Source

pub fn authority(&self) -> String

Returns <host> or <host>:<port> exactly as the origin writes it: the value of Host on every request to the gate.

Source

pub fn as_str(&self) -> String

Returns the origin text, <scheme>://<authority>.

Source

pub fn url(&self, path: &str) -> String

Returns the canonical URL of path, which should start with /: the URL a tenant request is signed over.

Trait Implementations§

Source§

impl Clone for CanonicalOrigin

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CanonicalOrigin

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CanonicalOrigin

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CanonicalOrigin

Source§

impl FromStr for CanonicalOrigin

Source§

type Err = ParseOriginError

The associated error which can be returned from parsing.
Source§

fn from_str(text: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for CanonicalOrigin

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CanonicalOrigin

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CanonicalOrigin

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V