pub struct FixedBaseResolver<'a, S: Spec> { /* private fields */ }
Expand description

A resolver against the fixed base.

Implementations

Creates a new resolver with the given base.

Examples
#[cfg(feature = "alloc")] {
use iri_string::format::ToDedicatedString;
use iri_string::resolve::FixedBaseResolver;
use iri_string::types::{IriAbsoluteStr, IriReferenceStr};

let base = IriAbsoluteStr::new("http://example.com/base/")?;
let resolver = FixedBaseResolver::new(base);

let reference = IriReferenceStr::new("../there")?;
let resolved = resolver.resolve(reference);

assert_eq!(resolved.to_dedicated_string(), "http://example.com/there");

Returns the base.

Examples
use iri_string::resolve::FixedBaseResolver;
use iri_string::types::{IriAbsoluteStr, IriReferenceStr};

let base = IriAbsoluteStr::new("http://example.com/base/")?;
let resolver = FixedBaseResolver::new(base);

assert_eq!(resolver.base(), base);

Resolves the given reference against the fixed base.

The task returned by this method does not normalize the resolution result. However, .. and . are recognized even when they are percent-encoded.

Failures

This function itself does not fail, but resolution algorithm defined by RFC 3986 can fail. In that case, serialization algorithm defined by WHATWG URL Standard would be automatically applied.

See the documentation of Normalized.

Examples
use iri_string::format::ToDedicatedString;
use iri_string::resolve::FixedBaseResolver;
use iri_string::types::{IriAbsoluteStr, IriReferenceStr};

let base = IriAbsoluteStr::new("http://example.com/base/")?;
let resolver = FixedBaseResolver::new(base);

let reference = IriReferenceStr::new("../there")?;
let resolved = resolver.resolve(reference);

assert_eq!(resolved.to_dedicated_string(), "http://example.com/there");

Note that .. and . path segments are recognized even when they are percent-encoded.

use iri_string::format::ToDedicatedString;
use iri_string::resolve::FixedBaseResolver;
use iri_string::types::{IriAbsoluteStr, IriReferenceStr};

let base = IriAbsoluteStr::new("HTTP://example.COM/base/base2/")?;
let resolver = FixedBaseResolver::new(base);

// `%2e%2e` is recognized as `..`.
// However, `dot%2edot` is NOT normalized into `dot.dot`.
let reference = IriReferenceStr::new("%2e%2e/../dot%2edot")?;
let resolved = resolver.resolve(reference);

// Resolved but not normalized.
assert_eq!(resolved.to_dedicated_string(), "HTTP://example.COM/dot%2edot");

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.