Wado

core:uri

URIs and URI references (RFC 3986) as identifiers: read one, resolve a reference against a URI, and write one back. Every scheme is read by the generic syntax, and only ASCII is admitted. A URI to fetch over HTTP is core:url's.

Synopsis

let base = Uri::from_str("https://example.com/schemas/root.json").unwrap();
let r = base.resolve(&UriReference::from_str("item.json#/$defs/id").unwrap());
assert r.to_string() == "https://example.com/schemas/item.json#/$defs/id";
assert r.fragment() matches { Some("/$defs/id") };

Structs

pub struct Uri

A URI (RFC 3986 §3): a URI reference with a scheme, so one that names a resource without a base, and one a reference resolves against. Two URIs are equal when their references are.

Fields are private.

pub fn resolve(&self, reference: &UriReference) -> Uri

reference resolved against this URI as its base (§5.2.2).

pub fn to_string(&self) -> String

The URI as Display writes it.

pub fn fragment(&self) -> Option<StrSlice>

The fragment, without its #.

pub fn without_fragment(&self) -> Uri

This URI with no fragment: the resource it names.

impl FromStr for Uri

fn from_str<S: AsStrSlice>(input: S) -> Result<Uri, UriError>

impl Serialize for Uri

fn serialize<S: Serializer>(&self, s: &mut S) -> Result<(), SerializeError>

impl Deserialize for Uri

fn deserialize<D: Deserializer>(d: &mut D) -> Result<Uri, DeserializeError>

impl Display for Uri

fn fmt(&self, f: &mut Formatter)

pub struct UriReference

A URI reference (RFC 3986 §4.1): a URI, or a relative reference to resolve against one. Every component is valid by construction. Two references are equal when their components are equal as written, the scheme's case aside.

Fields are private.

pub fn to_string(&self) -> String

The reference as Display writes it.

pub fn fragment(&self) -> Option<StrSlice>

The fragment, without its #.

pub fn without_fragment(&self) -> UriReference

This reference with no fragment.

impl FromStr for UriReference

fn from_str<S: AsStrSlice>(input: S) -> Result<UriReference, UriError>

impl Serialize for UriReference

fn serialize<S: Serializer>(&self, s: &mut S) -> Result<(), SerializeError>

impl Deserialize for UriReference

fn deserialize<D: Deserializer>(d: &mut D) -> Result<UriReference, DeserializeError>

impl Display for UriReference

fn fmt(&self, f: &mut Formatter)

pub struct UriError

Text outside the grammar of RFC 3986 Appendix A, at its byte offset.

offset: i32

message: String

impl Display for UriError

fn fmt(&self, f: &mut Formatter)