Struct did_toolkit::url::URL
source · pub struct URL {
pub did: DID,
pub parameters: Option<URLParameters>,
}Expand description
DID URL handling, including parsing, (de)-serialization, and manipulation according to https://www.w3.org/TR/did-core/#did-url-syntax.
DID URLs are nothing like hypertext URLs and it is strongly cautioned that you do not treat them as such.
The struct includes a DID as well as optional URLParameters to extend the DID. Converting to string, formatting for display, or serialization will cause the URL to be generated.
use did_toolkit::prelude::*;
let url = URL::parse("did:mymethod:alice/path?service=foo#fragment").unwrap();
assert_eq!(url, URL {
did: DID::parse("did:mymethod:alice").unwrap(),
parameters: Some(URLParameters{
path: Some("path".as_bytes().to_vec()),
fragment: Some("fragment".as_bytes().to_vec()),
service: Some("foo".to_string()),
..Default::default()
})
});
let url = URL {
did: DID::parse("did:mymethod:bob").unwrap(),
parameters: Some(URLParameters{
path: Some("path".as_bytes().to_vec()),
fragment: Some("fragment".as_bytes().to_vec()),
service: Some("bar".to_string()),
version_id: Some("1.0".to_string()),
..Default::default()
})
};
assert_eq!(url.to_string(), "did:mymethod:bob/path?service=bar&versionId=1.0#fragment");Fields§
§did: DID§parameters: Option<URLParameters>Implementations§
Trait Implementations§
source§impl<'de> Deserialize<'de> for URL
impl<'de> Deserialize<'de> for URL
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Ord for URL
impl Ord for URL
source§impl PartialOrd<URL> for URL
impl PartialOrd<URL> for URL
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Eq for URL
impl StructuralEq for URL
impl StructuralPartialEq for URL
Auto Trait Implementations§
impl RefUnwindSafe for URL
impl Send for URL
impl Sync for URL
impl Unpin for URL
impl UnwindSafe for URL
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.