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

A resolver against the fixed base.

If you want more control over how to resolve the buffer, create ResolutionTask by create_task method.

Implementations

Creates a new resolver with the given 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);

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

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

Resolves the given reference against the fixed base.

Enabled by alloc or std feature.

Failures

This fails if

  • memory allocation failed, or
  • the IRI referernce is unresolvable against the base.

To see examples of unresolvable IRIs, visit the documentation for resolve::Error.

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);

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

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

Creates a resolution task.

The returned ResolutionTask allows you to resolve the IRI without memory allocation, resolve to existing buffers, estimate required memory size, etc. If you need more control than resolve method, use this.

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);

let reference = IriReferenceStr::new("../there")?;
let task = resolver.create_task(reference);

let resolved = task.allocate_and_write()?;
assert_eq!(resolved, "http://example.com/there");

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.