Struct iri_string::resolve::FixedBaseResolver
source · [−]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
Auto Trait Implementations
impl<'a, S> RefUnwindSafe for FixedBaseResolver<'a, S>
impl<'a, S> Send for FixedBaseResolver<'a, S>
impl<'a, S> Sync for FixedBaseResolver<'a, S>
impl<'a, S> Unpin for FixedBaseResolver<'a, S>
impl<'a, S> UnwindSafe for FixedBaseResolver<'a, S>
Blanket Implementations
Mutably borrows from an owned value. Read more