Expand description
Content identifiers, decoded rather than glanced at.
didbot_schema::format::cid already checks CID strings, and it
deliberately does not decode: a client can write any CID into a record and
this server dereferences none of them, so the lenient alphabet-and-length
rule atproto specifies is the right check at that boundary. This type is
for the other direction. To encode a link into DAG-CBOR you need the CID’s
bytes, and to know that two links are the same link you need to compare
them; neither is answerable from the string.
What atproto permits is a narrow slice of what a CID can be, and all of it is enforced here, because a value this crate cannot re-encode byte for byte is a value it must not accept:
- version 1. CIDv0 is a valid IPFS identifier, is base58 with no multibase prefix at all, and is not permitted in atproto.
- the multibase is base32, lowercase, unpadded — the
bprefix. Another multibase would decode to the same bytes and print back differently. - the multihash is sha-256, 32 bytes.
- the codec is DAG-CBOR or raw. Everything atproto links to is one or the other: a record or a blob.
Structs§
- Cid
- A content identifier, held as the bytes it hashes and prints from.
- RawHasher
- A raw-block CID computed over bytes that arrive a chunk at a time.
Enums§
- CidError
- Why a string or a byte sequence is not a CID this crate can use.
Constants§
- BASE32_
PREFIX 🔒 - The multibase prefix for lowercase unpadded base32.
- DAG_
CBOR - The multicodec for DAG-CBOR, which is what a link to a record carries.
- DIGEST_
LENGTH 🔒 - How long a sha-256 digest is.
- RAW
- The multicodec for raw bytes, which is what a link to a blob carries.
- SHA2_
256 🔒 - The multihash code for sha-256.
Functions§
- read_
varint 🔒 - Reads an unsigned LEB128 varint, advancing
inputpast it. - write_
varint 🔒 - Appends an unsigned LEB128 varint, the multiformats encoding.