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

  • Plc

    Self-authenticating DID method developed specifically for use with atproto.

  • Web

    W3C 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)

Parse a string into a valid Did type If the value is not a valid string then an error is returned.

Examples

import possum/did

let string = "did:plc:k5vecqzf4d5mdvkcu3mx6l5g"
let assert Ok(did) = did.parse(string)

See also: Did

pub fn to_string(self: Did) -> String

Convert a DID to a string.

Examples

import possum/did

let assert Ok(did) = did.parse("did:plc:k5vecqzf4d5mdvkcu3mx6l5g")
let string = did.to_string(did)

assert string == "did:plc:k5vecqzf4d5mdvkcu3mx6l5g"

See also: Did

Search Document