Struct RiAbsoluteStr
struct RiAbsoluteStr<S> { ... }
A borrowed slice of an absolute IRI without fragment part.
This corresponds to absolute-IRI rule in RFC 3987
(and absolute-URI rule in RFC 3986).
In other words, this is RiStr without fragment part.
If you want to accept fragment part, use RiStr.
Valid values
This type can have an absolute IRI without fragment part.
# use IriAbsoluteStr;
assert!;
assert!;
// Scheme `foo` and empty path.
assert!;
// `foo://.../` below are all allowed. See the crate documentation for detail.
assert!;
assert!;
assert!;
assert!;
assert!;
Relative IRI is not allowed.
# use IriAbsoluteStr;
// This is relative path.
assert!;
// `/foo/bar` is an absolute path, but it is authority-relative.
assert!;
// `//foo/bar` is termed "network-path reference",
// or usually called "protocol-relative reference".
assert!;
// Empty string is not a valid absolute IRI.
assert!;
Fragment part (such as trailing #foo) is not allowed.
# use IriAbsoluteStr;
// Fragment part is not allowed.
assert!;
Some characters and sequences cannot used in an absolute IRI.
# use IriAbsoluteStr;
// `<` and `>` cannot directly appear in an absolute IRI.
assert!;
// Broken percent encoding cannot appear in an absolute IRI.
assert!;
assert!;
Implementations
impl RiAbsoluteStr<IriSpec>
fn encode_to_uri(self: &Self) -> MappedToUri<'_, Self>Percent-encodes the IRI into a valid URI that identifies the equivalent resource.
If you need more precise control over memory allocation and buffer handling, use [
MappedToUri]crate::convert::MappedToUritype.Examples
# use Error; # # Ok::fn as_uri(self: &Self) -> Option<&UriAbsoluteStr>Converts an IRI into a URI without modification, if possible.
This is semantically equivalent to
UriAbsoluteStr::new(self.as_str()).ok().Examples
# use Error; use ; let ascii_iri = new?; assert_eq!; let nonascii_iri = new?; assert_eq!; # Ok::
impl<S: Spec> RiAbsoluteStr<S>
fn scheme_str(self: &Self) -> &strReturns the scheme.
The following colon is truncated.
Examples
# use Error; use IriAbsoluteStr; let iri = new?; assert_eq!; # Ok::Returns the authority.
The leading
//is truncated.Examples
# use Error; use IriAbsoluteStr; let iri = new?; assert_eq!; # Ok::# use Error; use IriAbsoluteStr; let iri = new?; assert_eq!; # Ok::fn path_str(self: &Self) -> &strReturns the path.
Examples
# use Error; use IriAbsoluteStr; let iri = new?; assert_eq!; # Ok::# use Error; use IriAbsoluteStr; let iri = new?; assert_eq!; # Ok::fn query(self: &Self) -> Option<&RiQueryStr<S>>Returns the query.
The leading question mark (
?) is truncated.Examples
# use Error; use ; let iri = new?; let query = new?; assert_eq!; # Ok::# use Error; use IriAbsoluteStr; let iri = new?; assert_eq!; # Ok::fn query_str(self: &Self) -> Option<&str>Returns the query in a raw string slice.
The leading question mark (
?) is truncated.Examples
# use Error; use IriAbsoluteStr; let iri = new?; assert_eq!; # Ok::# use Error; use IriAbsoluteStr; let iri = new?; assert_eq!; # Ok::Returns the authority components.
Examples
# use Error; use IriAbsoluteStr; let iri = new?; let authority = iri.authority_components .expect; assert_eq!; assert_eq!; assert_eq!; # Ok::# use Error; use IriAbsoluteStr; let iri = new?; assert_eq!; # Ok::
impl<S: Spec> RiAbsoluteStr<S>
fn ensure_rfc3986_normalizable(self: &Self) -> Result<(), Error>Returns Ok
(())if the IRI is normalizable by the RFC 3986 algorithm.Examples
# use Error; use IriAbsoluteStr; let iri = new?; assert!; let iri2 = new?; // The normalization result would be `scheme://bar` according to RFC // 3986, but it is unintended and should be treated as a failure. // This crate automatically handles this case so that `.normalize()` won't fail. assert!; # Ok::fn is_normalized(self: &Self) -> boolReturns
trueif the IRI is already normalized.This returns the same result as
self.normalize().to_string() == self, but does this more efficiently without heap allocation.Examples
# use Error; # # Ok::# use Error; # # Ok::# use Error; # # Ok::fn is_normalized_rfc3986(self: &Self) -> boolReturns
trueif the IRI is already normalized.This returns the same result as
self.ensure_rfc3986_normalizable() && (self.normalize().to_string() == self), does this more efficiently without heap allocation.Examples
# use Error; # # Ok::# use Error; # # Ok::# use Error; # # Ok::Returns
trueif the IRI is already normalized in the sense ofnormalize_but_preserve_authorityless_relative_pathmethod.This returns the same result as
self.normalize_but_preserve_authorityless_relative_path().to_string() == self, but does this more efficiently without heap allocation.Examples
# use Error; # # Ok::# use Error; # # Ok::# use Error; # # Ok::fn normalize(self: &Self) -> Normalized<'_, Self>Returns the normalized IRI.
Notes
For some abnormal IRIs, the normalization can produce semantically incorrect string that looks syntactically valid. To avoid security issues by this trap, the normalization algorithm by this crate automatically applies the workaround.
If you worry about this, test by
RiAbsoluteStr::ensure_rfc3986_normalizablemethod orNormalized::ensure_rfc3986_normalizablebefore using the result string.Examples
# use Error; # # Ok::Returns the normalized IRI, but preserving dot segments in relative path if the authority component is absent.
This normalization would be similar to that of WHATWG URL Standard while this implementation is not guaranteed to stricly follow the spec.
Note that this normalization algorithm is not compatible with RFC 3986 algorithm for some inputs.
Note that case normalization and percent-encoding normalization will still be applied to any path.
Examples
# use Error; # # Ok::# use Error; # # Ok::fn mask_password(self: &Self) -> PasswordMasked<'_, Self>Returns the proxy to the IRI with password masking feature.
Examples
# use Error; # # Ok::
impl<S: crate::spec::Spec> RiAbsoluteStr<S>
fn new(s: &str) -> Result<&Self, Error>Creates a new string.
unsafe fn new_unchecked(s: &str) -> &SelfCreates a new string without validation.
This does not validate the given string, so it is caller's responsibility to ensure the given string is valid.
Safety
The given string must be syntactically valid as
Selftype. If not, any use of the returned value or the call of this function itself may result in undefined behavior.fn as_str(self: &Self) -> &strReturns
&str.fn len(self: &Self) -> usizeReturns the string length.
fn is_empty(self: &Self) -> boolReturns whether the string is empty.
impl<S> Freeze for RiAbsoluteStr<S>
impl<S> RefUnwindSafe for RiAbsoluteStr<S>
impl<S> Send for RiAbsoluteStr<S>
impl<S> Sized for RiAbsoluteStr<S>
impl<S> Sync for RiAbsoluteStr<S>
impl<S> Unpin for RiAbsoluteStr<S>
impl<S> UnsafeUnpin for RiAbsoluteStr<S>
impl<S> UnwindSafe for RiAbsoluteStr<S>
impl<S: Spec> Buildable for RiAbsoluteStr<S>
impl<S: crate::spec::Spec> AsRef for RiAbsoluteStr<S>
fn as_ref(self: &Self) -> &RiAbsoluteStr<S>
impl<S: crate::spec::Spec> AsRef for RiAbsoluteStr<S>
fn as_ref(self: &Self) -> &RiStr<S>
impl<S: crate::spec::Spec> AsRef for RiAbsoluteStr<S>
fn as_ref(self: &Self) -> &str
impl<S: crate::spec::Spec> AsRef for RiAbsoluteStr<S>
fn as_ref(self: &Self) -> &RiReferenceStr<S>
impl<S: crate::spec::Spec> Debug for RiAbsoluteStr<S>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<S: crate::spec::Spec> Display for RiAbsoluteStr<S>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<S: crate::spec::Spec> Eq for RiAbsoluteStr<S>
impl<S: crate::spec::Spec> Hash for RiAbsoluteStr<S>
fn hash<H: core::hash::Hasher>(self: &Self, state: &mut H)
impl<S: crate::spec::Spec> Ord for RiAbsoluteStr<S>
fn cmp(self: &Self, other: &Self) -> Ordering
impl<S: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, other: &Self) -> bool
impl<S: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &Cow<'_, str>) -> bool
impl<S: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &&str) -> bool
impl<S: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &str) -> bool
impl<S: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &Cow<'_, str>) -> Option<Ordering>
impl<S: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &&str) -> Option<Ordering>
impl<S: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &str) -> Option<Ordering>
impl<S: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, other: &Self) -> Option<Ordering>
impl<S: crate::spec::Spec> ToOwned for RiAbsoluteStr<S>
fn to_owned(self: &Self) -> <Self as >::Owned
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &Cow<'_, RiStr<T>>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &&RiStr<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &RiStr<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &RiReferenceString<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &Cow<'_, RiReferenceStr<T>>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &&RiReferenceStr<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &RiReferenceStr<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &RiAbsoluteString<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiAbsoluteStr<S>
fn eq(self: &Self, o: &RiString<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiAbsoluteStr<T>
fn eq(self: &Self, o: &&RiAbsoluteStr<S>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &RiAbsoluteString<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &RiString<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &Cow<'_, RiStr<T>>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &&RiStr<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &RiStr<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &RiReferenceString<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &Cow<'_, RiReferenceStr<T>>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &&RiReferenceStr<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiAbsoluteStr<S>
fn partial_cmp(self: &Self, o: &RiReferenceStr<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiAbsoluteStr<T>
fn partial_cmp(self: &Self, o: &&RiAbsoluteStr<S>) -> Option<Ordering>
impl<T> Any for RiAbsoluteStr<S>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for RiAbsoluteStr<S>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for RiAbsoluteStr<S>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> ToString for RiAbsoluteStr<S>
fn to_string(self: &Self) -> String