pub struct Link(pub(crate) String);
Expand description
A normalized URL used as the redirect destination. This ensures that the link is a valid absolute HTTP(S) URL.
The resulting Link
is guaranteed to have an http
or https
scheme, be
an absolute URL, not have a password, and be properly percent encoded. Note
that this doesn’t aim to make invalid URLs valid (e.g. by percent encoding
non-ascii characters), but may normalize the provided URL (e.g. by decoding
percent-encoded non-reserved characters or by lowercasing the host). Link
should not be used to create a new, valid, properly encoded URL from user
input, only to verify one, as it doesn’t provide much useful feedback or
help with encoding an almost valid URL, nor does it do much useful
guesswork.
Tuple Fields§
§0: String
Implementations§
Source§impl Link
impl Link
Sourcepub(crate) const VALID_SCHEMES: &'static [&'static str]
pub(crate) const VALID_SCHEMES: &'static [&'static str]
Valid Link URL schemes
Sourcepub fn new(url: &str) -> Result<Self, LinkError>
pub fn new(url: &str) -> Result<Self, LinkError>
Create a new Link, checking the provided string.
§Errors
This returns an error if the passed url
is invalid
(LinkError::Invalid
), has a password (LinkError::Unsafe
), has an
invalid scheme (LinkError::Scheme
, valid schemes are http
and
https
), or is not absolute (LinkError::Relative
).
Sourcepub const fn new_unchecked(url: String) -> Self
pub const fn new_unchecked(url: String) -> Self
Create a new Link without performing any checks.
§Safety
This makes no guarantees about the contents of the Link, the validity of the link must be ensured some other way before calling this.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Returns the string this Link
wraps, consuming self
.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Link
impl<'de> Deserialize<'de> for Link
Source§fn 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>,
Source§impl Ord for Link
impl Ord for Link
Source§impl PartialOrd for Link
impl PartialOrd for Link
impl Eq for Link
impl StructuralPartialEq for Link
Auto Trait Implementations§
impl Freeze for Link
impl RefUnwindSafe for Link
impl Send for Link
impl Sync for Link
impl Unpin for Link
impl UnwindSafe for Link
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,
§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> 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