Struct primitives::util::ApiUrl
source · pub struct ApiUrl(_);
Expand description
A safe Url to use in REST API calls.
It makes sure to always end the Url with /
,
however it doesn’t check for the existence of a file, e.g. /path/a-file.html
Underneath it uses url::Url
, so all the validation from there is enforced,
with additional validation which doesn’t allow having:
Scheme
different thathttp
&https
- Non-base
url
s likedata:
&mailto:
Fragment
, e.g.#fragment
Query
, e.g.?query_param=value
,?query_param
,?query=value&....
, etc.
Implementations
sourceimpl ApiUrl
impl ApiUrl
pub fn parse(input: &str) -> Result<Self, Error>
sourcepub fn join(&self, endpoint: &str) -> Result<Url, ParseError>
pub fn join(&self, endpoint: &str) -> Result<Url, ParseError>
The Endpoint of which we want to get an url to (strips prefixed /
from the endpoint),
which can can include:
- path
- query
- fragments - usually should not be used for requesting API resources from server
This method does not check if a file is present
This method strips the starting /
of the endpoint, if there is one
pub fn to_url(&self) -> Url
pub fn as_str(&self) -> &str
Trait Implementations
sourceimpl<'de> Deserialize<'de> for ApiUrl
impl<'de> Deserialize<'de> for ApiUrl
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for ApiUrl
impl Ord for ApiUrl
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<ApiUrl> for ApiUrl
impl PartialOrd<ApiUrl> for ApiUrl
sourcefn partial_cmp(&self, other: &ApiUrl) -> Option<Ordering>
fn partial_cmp(&self, other: &ApiUrl) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for ApiUrl
impl StructuralEq for ApiUrl
impl StructuralPartialEq for ApiUrl
Auto Trait Implementations
impl RefUnwindSafe for ApiUrl
impl Send for ApiUrl
impl Sync for ApiUrl
impl Unpin for ApiUrl
impl UnwindSafe for ApiUrl
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more