pub struct Url { /* private fields */ }Expand description
When configuring fronting, some configurations will require a specific backend host to be used for the request to be properly reverse proxied.
This type only describes a host and its configured front domains - it carries no rotation
state. A crate::Client tracks, per configured host, which front (if any) is currently in
use; see crate::rotation::RotationManager.
Implementations§
Source§impl Url
impl Url
Sourcepub fn new<U: IntoUrl>(url: U, fronts: Option<Vec<U>>) -> Result<Self, Error>
pub fn new<U: IntoUrl>(url: U, fronts: Option<Vec<U>>) -> Result<Self, Error>
Create a new FrontedUrl instance with the given something that can be parsed as a URL
and optional tunneling domains
Sourcepub fn parse(s: &str) -> Result<Self, ParseError>
pub fn parse(s: &str) -> Result<Self, ParseError>
Parse an absolute URL from a string.
Sourcepub fn first_front_str(&self) -> Option<&str>
pub fn first_front_str(&self) -> Option<&str>
Return the string representation of the first configured front host (domain or IP address) for this URL, if any.
This does not reflect any client’s front-rotation state - it is only meaningful before
rotation has happened, or for hosts with a single configured front. For the front a
crate::Client is actually using, see its rotation-aware accessors instead.
Sourcepub fn host_str(&self) -> Option<&str>
pub fn host_str(&self) -> Option<&str>
Return the string representation of the host (domain or IP address) for this URL, if any.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Return the serialization of this URL.
This is fast since that serialization is already stored in the inner url::Url struct. Note that this does not reflect any client’s front-rotation state.
Sourcepub fn scheme(&self) -> &str
pub fn scheme(&self) -> &str
Return the scheme of this URL, lower-cased, as an ASCII string without the ‘:’ delimiter.
Sourcepub fn query_pairs(&self) -> Parse<'_> ⓘ
pub fn query_pairs(&self) -> Parse<'_> ⓘ
Parse the URL’s query string, if any, as application/x-www-form-urlencoded and return an iterator of (key, value) pairs.
Sourcepub fn query_pairs_mut(&mut self) -> Serializer<'_, UrlQuery<'_>>
pub fn query_pairs_mut(&mut self) -> Serializer<'_, UrlQuery<'_>>
Manipulate this URL’s query string, viewed as a sequence of name/value pairs in application/x-www-form-urlencoded syntax.
Sourcepub fn set_query(&mut self, query: Option<&str>)
pub fn set_query(&mut self, query: Option<&str>)
Change this URL’s query string. If query is None, this URL’s query string will be cleared.
Sourcepub fn set_scheme(&mut self, scheme: &str)
pub fn set_scheme(&mut self, scheme: &str)
Change this URL’s scheme.
Sourcepub fn set_host(&mut self, host: &str)
pub fn set_host(&mut self, host: &str)
Change this URL’s host.
Removing the host (calling this with None) will also remove any username, password, and port number.
Sourcepub fn set_port(&mut self, port: u16)
pub fn set_port(&mut self, port: u16)
Change this URL’s port number.
Note that default port numbers are not reflected in the serialization.
If this URL is cannot-be-a-base, does not have a host, or has the file scheme; do nothing and return Err.
Sourcepub fn path_segments(&self) -> Option<Split<'_, char>>
pub fn path_segments(&self) -> Option<Split<'_, char>>
Return an object with methods to manipulate this URL’s path segments.
Return Err(()) if this URL is cannot-be-a-base.
Sourcepub fn path_segments_mut(&mut self) -> Result<PathSegmentsMut<'_>, ()>
pub fn path_segments_mut(&mut self) -> Result<PathSegmentsMut<'_>, ()>
Return an object with methods to manipulate this URL’s path segments.
Return Err(()) if this URL is cannot-be-a-base.
Trait Implementations§
impl Eq for Url
impl StructuralPartialEq for Url
Auto Trait Implementations§
impl Freeze for Url
impl RefUnwindSafe for Url
impl Send for Url
impl Sync for Url
impl Unpin for Url
impl UnsafeUnpin for Url
impl UnwindSafe for Url
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 more