pub struct Uri(/* private fields */);Expand description
A URI (RFC 3986) stored exactly as written: no normalization, no percent-decoding, no case folding.
DID documents carry URIs in alsoKnownAs and serviceEndpoint, and DID Core requires a
consumer to hand them on unchanged, so this type checks the generic syntax and nothing more:
a scheme, then characters from the RFC 3986 sets (unreserved, reserved, pct-encoded),
with at most one #. Two URIs are equal exactly when their strings are equal.
Every Did and DidUrl is a Uri; use From to convert.
§Examples
use identity_kit::did::Uri;
let uri = Uri::parse("https://bar.example.com")?;
assert_eq!(uri.as_str(), "https://bar.example.com"); // no trailing slash added
assert_eq!(uri.scheme(), "https");
assert!(Uri::parse("not a uri").is_err());
assert!(Uri::parse("/relative/path").is_err());Implementations§
Source§impl Uri
impl Uri
Sourcepub fn parse(s: &str) -> Result<Self, DidError>
pub fn parse(s: &str) -> Result<Self, DidError>
Parses a URI, checking the RFC 3986 generic syntax.
§Errors
DidError::InvalidChar names the first byte that is not allowed in a URI, including a
missing or malformed scheme; DidError::InvalidPercentEncoding an incomplete %xx.
Sourcepub fn is_did_url(&self) -> bool
pub fn is_did_url(&self) -> bool
Whether this URI is a DID or a DID URL.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Uri
impl<'de> Deserialize<'de> for Uri
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Uri
Source§impl From<Uri> for ServiceEndpoint
impl From<Uri> for ServiceEndpoint
Source§impl Ord for Uri
impl Ord for Uri
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Uri
impl PartialOrd for Uri
impl StructuralPartialEq for Uri
Auto Trait Implementations§
impl Freeze for Uri
impl RefUnwindSafe for Uri
impl Send for Uri
impl Sync for Uri
impl Unpin for Uri
impl UnsafeUnpin for Uri
impl UnwindSafe for Uri
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.