Struct RiRelativeStr
struct RiRelativeStr<S> { ... }
A borrowed slice of a relative IRI reference.
This corresponds to irelative-ref rule in RFC 3987
(and relative-ref rule in RFC 3986).
The rule for irelative-ref is irelative-part [ "?" iquery ] [ "#" ifragment ].
Valid values
This type can have a relative IRI reference.
# use IriRelativeStr;
assert!;
assert!;
assert!;
assert!;
assert!;
assert!;
assert!;
// The first path component can have colon if the path is absolute.
assert!;
// Second or following path components can have colon.
assert!;
assert!;
Absolute form of a reference is not allowed.
# use IriRelativeStr;
assert!;
// The first path component cannot have colon, if the path is not absolute.
assert!;
assert!;
assert!;
assert!;
assert!;
assert!;
assert!;
Some characters and sequences cannot used in an IRI reference.
# use IriRelativeStr;
// `<` and `>` cannot directly appear in a relative IRI reference.
assert!;
// Broken percent encoding cannot appear in a relative IRI reference.
assert!;
assert!;
Implementations
impl RiRelativeStr<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<&UriRelativeStr>Converts an IRI into a URI without modification, if possible.
This is semantically equivalent to
UriRelativeStr::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> RiRelativeStr<S>
Returns the authority.
The leading
//is truncated.Examples
# use Error; use IriRelativeStr; let iri = new?; assert_eq!; # Ok::# use Error; use IriRelativeStr; let iri = new?; assert_eq!; # Ok::fn path_str(self: &Self) -> &strReturns the path.
Examples
# use Error; use IriRelativeStr; let iri = new?; assert_eq!; # Ok::# use Error; use IriRelativeStr; 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 ; let iri = new?; let query = 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 IriRelativeStr; let iri = new?; assert_eq!; # Ok::# use Error; use IriRelativeStr; let iri = new?; assert_eq!; # Ok::fn fragment(self: &Self) -> Option<&RiFragmentStr<S>>Returns the fragment part if exists.
A leading
#character is truncated if the fragment part exists.Examples
If the IRI has a fragment part,
Some(_)is returned.# use ; let iri = new?; let fragment = new?; assert_eq!; # Ok::# use ; let iri = new?; let fragment = new?; assert_eq!; # Ok::When the fragment part exists but is empty string,
Some(_)is returned.# use ; let iri = new?; let fragment = new?; assert_eq!; # Ok::If the IRI has no fragment,
Noneis returned.# use ; let iri = new?; assert_eq!; # Ok::fn fragment_str(self: &Self) -> Option<&str>Returns the fragment part as a raw string slice if exists.
A leading
#character is truncated if the fragment part exists.Examples
If the IRI has a fragment part,
Some(_)is returned.# use ; let iri = new?; assert_eq!; # Ok::# use ; let iri = new?; assert_eq!; # Ok::When the fragment part exists but is empty string,
Some(_)is returned.# use ; let iri = new?; assert_eq!; # Ok::If the IRI has no fragment,
Noneis returned.# use ; let iri = new?; assert_eq!; # Ok::Returns the authority components.
Examples
# use Error; use IriRelativeStr; let iri = new?; let authority = iri.authority_components .expect; assert_eq!; assert_eq!; assert_eq!; # Ok::# use Error; use IriRelativeStr; let iri = new?; assert_eq!; # Ok::
impl<S: Spec> RiRelativeStr<S>
fn resolve_against<'a>(self: &'a Self, base: &'a RiAbsoluteStr<S>) -> Normalized<'a, RiStr<S>>Returns resolved IRI against the given base IRI.
For IRI reference resolution output examples, see RFC 3986 section 5.4.
If you are going to resolve multiple references against the common base, consider using
FixedBaseResolver.Strictness
The IRI parsers provided by this crate is strict (e.g.
http:gis always interpreted as a composition of the schemehttpand the pathg), so backward compatible parsing and resolution are not provided. About parser and resolver strictness, see RFC 3986 section 5.4.2:Some parsers allow the scheme name to be present in a relative reference if it is the same as the base URI scheme. This is considered to be a loophole in prior specifications of partial URI RFC1630. Its use should be avoided but is allowed for backward compatibility.
Failures
This method itself does not fail, but IRI resolution without WHATWG URL Standard serialization can fail in some minor cases.
To see examples of such unresolvable IRIs, visit the documentation for [
normalize]crate::normalizemodule.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> RiRelativeStr<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 RiRelativeStr<S>
impl<S> RefUnwindSafe for RiRelativeStr<S>
impl<S> Send for RiRelativeStr<S>
impl<S> Sized for RiRelativeStr<S>
impl<S> Sync for RiRelativeStr<S>
impl<S> Unpin for RiRelativeStr<S>
impl<S> UnsafeUnpin for RiRelativeStr<S>
impl<S> UnwindSafe for RiRelativeStr<S>
impl<S: Spec> Buildable for RiRelativeStr<S>
impl<S: crate::spec::Spec> AsRef for RiRelativeStr<S>
fn as_ref(self: &Self) -> &RiReferenceStr<S>
impl<S: crate::spec::Spec> AsRef for RiRelativeStr<S>
fn as_ref(self: &Self) -> &RiRelativeStr<S>
impl<S: crate::spec::Spec> AsRef for RiRelativeStr<S>
fn as_ref(self: &Self) -> &str
impl<S: crate::spec::Spec> Debug for RiRelativeStr<S>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<S: crate::spec::Spec> Display for RiRelativeStr<S>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<S: crate::spec::Spec> Eq for RiRelativeStr<S>
impl<S: crate::spec::Spec> Hash for RiRelativeStr<S>
fn hash<H: core::hash::Hasher>(self: &Self, state: &mut H)
impl<S: crate::spec::Spec> Ord for RiRelativeStr<S>
fn cmp(self: &Self, other: &Self) -> Ordering
impl<S: crate::spec::Spec> PartialEq for RiRelativeStr<S>
fn eq(self: &Self, other: &Self) -> bool
impl<S: crate::spec::Spec> PartialEq for RiRelativeStr<S>
fn eq(self: &Self, o: &Cow<'_, str>) -> bool
impl<S: crate::spec::Spec> PartialEq for RiRelativeStr<S>
fn eq(self: &Self, o: &&str) -> bool
impl<S: crate::spec::Spec> PartialEq for RiRelativeStr<S>
fn eq(self: &Self, o: &str) -> bool
impl<S: crate::spec::Spec> PartialOrd for RiRelativeStr<S>
fn partial_cmp(self: &Self, o: &Cow<'_, str>) -> Option<Ordering>
impl<S: crate::spec::Spec> PartialOrd for RiRelativeStr<S>
fn partial_cmp(self: &Self, o: &&str) -> Option<Ordering>
impl<S: crate::spec::Spec> PartialOrd for RiRelativeStr<S>
fn partial_cmp(self: &Self, o: &str) -> Option<Ordering>
impl<S: crate::spec::Spec> PartialOrd for RiRelativeStr<S>
fn partial_cmp(self: &Self, other: &Self) -> Option<Ordering>
impl<S: crate::spec::Spec> ToOwned for RiRelativeStr<S>
fn to_owned(self: &Self) -> <Self as >::Owned
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiRelativeStr<S>
fn eq(self: &Self, o: &RiReferenceString<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiRelativeStr<S>
fn eq(self: &Self, o: &&RiReferenceStr<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiRelativeStr<S>
fn eq(self: &Self, o: &RiReferenceStr<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiRelativeStr<S>
fn eq(self: &Self, o: &Cow<'_, RiReferenceStr<T>>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiRelativeStr<S>
fn eq(self: &Self, o: &RiRelativeString<T>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialEq for RiRelativeStr<T>
fn eq(self: &Self, o: &&RiRelativeStr<S>) -> bool
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiRelativeStr<S>
fn partial_cmp(self: &Self, o: &RiReferenceStr<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiRelativeStr<S>
fn partial_cmp(self: &Self, o: &Cow<'_, RiReferenceStr<T>>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiRelativeStr<S>
fn partial_cmp(self: &Self, o: &RiRelativeString<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiRelativeStr<S>
fn partial_cmp(self: &Self, o: &RiReferenceString<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiRelativeStr<S>
fn partial_cmp(self: &Self, o: &&RiReferenceStr<T>) -> Option<Ordering>
impl<S: crate::spec::Spec, T: crate::spec::Spec> PartialOrd for RiRelativeStr<T>
fn partial_cmp(self: &Self, o: &&RiRelativeStr<S>) -> Option<Ordering>
impl<T> Any for RiRelativeStr<S>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for RiRelativeStr<S>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for RiRelativeStr<S>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> ToString for RiRelativeStr<S>
fn to_string(self: &Self) -> String