possum/did
Types
AT Protocol uses Decentralized Identifiers (DIDs) universally-unique identifiers which represent data repos. For example:
did:plc:k5vecqzf4d5mdvkcu3mx6l5g
└─┘ └──────────────────────┘
method identifier
Documentation: Decentralized Identifiers
See also: parse
pub opaque type Did
The core DID standard and describes a framework for compliant identifier systems (“DID methods”), of which several exist. To ensure broad interoperation across the ecosystem, atproto only supports a small number of “blessed” DID methods.
Documentation: Blessed DID Methods
pub type Method {
Plc
Web
}
Constructors
-
PlcSelf-authenticating DID method developed specifically for use with atproto.
-
WebW3C community draft based on HTTPS (and DNS). The identifier section is a hostname.
pub type ParseError {
InvalidRegexPattern(pattern: String)
InvalidSyntax(value: String)
InvalidDidMethod(value: String)
}
Constructors
-
InvalidRegexPattern(pattern: String)Regex failed to compile
-
InvalidSyntax(value: String)String does not have a valid DID format
-
InvalidDidMethod(value: String)Method can only be “plc” or “web”
Values
pub fn decoder() -> decode.Decoder(Did)
pub fn indentifer(self: Did) -> String
Return the DID identifier.
This function does not convert the value into a valid DID format, for that use to_string.
Examples
import possum/did
let assert Ok(did) = did.parse("did:plc:k5vecqzf4d5mdvkcu3mx6l5g")
let identifier = did.identifier(did)
assert identifier == "k5vecqzf4d5mdvkcu3mx6l5g"
pub fn method(self: Did) -> Method
Return the DID method
Examples
import possum/did
let assert Ok(did) = did.parse("did:plc:k5vecqzf4d5mdvkcu3mx6l5g")
let method = did.method(did)
assert method == did.Plc
pub fn parse(content: String) -> Result(Did, ParseError)