Skip to main content

Crate ratproto_did

Crate ratproto_did 

Source
Expand description

This library implements a memory-efficient container for atproto DIDs.

The Did type is guaranteed to take up exactly 16 bytes.

  • did:plc is represented with just these 16 bytes
  • did:web uses up to 255 bytes of heap
  • other DID methods (not officially supported by atproto) allocate heap space as needed

The most common DID in the Atmosphere (the atproto ecosystem) is did:plc. Currently, its identifier is exactly 24 characters of base32. At 5 bits per characters, that is 120 bits, or 15 bytes. This leaves just enough space for a single-byte discriminator, making this implementation highly-optimized for did:plc while also allowing it to represent other DID methods. The PLC identifier is expected to be exactly 24 characters long.

Atproto currently only supports host-level did:web DIDs, so the identifier is a web domain. The maximum length of a web domain is 255 bytes, so a Did representing a did:web allocates the necessary space on the heap. Parsing a did:web with an unsupported format fails. The only exception is localhost, which supports an optional port (as in localhost%3A12345).

Other DID methods are currently unsupported by atproto, but not strictly disallowed. DID methods that are not plc or web have their method and identifier strings allocated on the heap.


Did supports serde using an optional feature. Values are serialized and deserialized using the standard string representation.

Structs§

Did
A tightly-packed representation of DIDs for atproto.
ParseDidError
An error which can be returned when parsing a DID.

Enums§

DidErrorKind
Details about why a DID failed to parse.
DidKind
Which method does this Did represent?