pub struct Did(/* private fields */);Expand description
A W3C Decentralized Identifier (did:key:…, did:web:…, …), carried on capnp wires as
Text (W3C DID strings — see https://www.w3.org/TR/did-core/) and mapped to this Rust
newtype via a field-level $domainType("hyprstream_rpc::identity::Did") annotation. The
generated ToCapnp/FromCapnp impls write via Did::as_str and read via Did::new.
Construction is lenient — Did::new performs no validation, so deserializing a
malformed wire value never fails at the boundary. Strict validation lives at the
admission gate (crate::admission); this type is a typed string, not a policy check.
did:key is the self-certifying interop arm (the key is the identity; algorithm-agile
via multicodec and iroh-convertible), while did:web covers operated nodes whose keys
live as DID-document verification methods.
Wire representation is Text; serde (de)serializes transparently as the inner string.
Cloneable, hashable, orderable (lexicographic on the inner string), and usable as a map
key — including ordered maps / TtlCache<Did, _> (#524 placement liveness directory).
Default yields an empty DID (Did("")) — the generated capnp data structs that carry a
Did field derive Default, and an absent Text field reads back as the empty string.
Implementations§
Source§impl Did
impl Did
Sourcepub fn new(did: String) -> Self
pub fn new(did: String) -> Self
Wrap a DID string verbatim. No validation — strict checks belong at the admission gate (see the type docs).
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consume the newtype, returning the owned DID string.
Sourcepub fn is_did_key(&self) -> bool
pub fn is_did_key(&self) -> bool
Whether this is a did:key identifier (the self-certifying interop arm).
Sourcepub fn is_did_web(&self) -> bool
pub fn is_did_web(&self) -> bool
Whether this is a did:web identifier (operated nodes resolved via DID document).
Sourcepub fn is_did_at9p(&self) -> bool
pub fn is_did_at9p(&self) -> bool
Whether this is a did:at9p identifier — the PQC-hybrid, self-certifying
identity (did:at9p:<cid512>, #879). The authoritative end of the
alsoKnownAs aliasing bridge (#896 / D4): when a did:web / did:key
and a did:at9p mutually attest each other, the content-verified at9p
capsule is the stronger identity.
The capsule GATE pipeline that verifies a did:at9p and derives its
PqHybrid key material is epic #880 (D2); the method-dispatched resolver
reserves the arm but does not yet resolve it (fails closed until #894).
Sourcepub fn to_ed25519(&self) -> Result<[u8; 32]>
pub fn to_ed25519(&self) -> Result<[u8; 32]>
Decode the raw 32-byte Ed25519 public key from a did:key identifier.
Returns Err for a non-did:key DID, a non-Ed25519 multicodec, or a malformed body.
Sourcepub fn from_ed25519(key: &[u8; 32]) -> Self
pub fn from_ed25519(key: &[u8; 32]) -> Self
Construct a did:key (Ed25519) identifier from a raw 32-byte public key.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Did
impl<'de> Deserialize<'de> for Did
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>,
Source§impl Ord for Did
impl Ord for Did
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Did
impl PartialOrd for Did
impl Eq for Did
impl StructuralPartialEq for Did
Auto Trait Implementations§
impl Freeze for Did
impl RefUnwindSafe for Did
impl Send for Did
impl Sync for Did
impl Unpin for Did
impl UnsafeUnpin for Did
impl UnwindSafe for Did
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more