atproto_repo/cid

The “blessed” atproto CID: CIDv1, SHA-256, with the DAG-CBOR or raw codec. Anything else is rejected at parse time, so a Cid value is always one atproto accepts.

Types

Cid

opaque
pub opaque type Cid
pub type CidError {
  UnsupportedMultibase(prefix: String)
  InvalidBase32
  Truncated
  MalformedVarint
  UnsupportedVersion(Int)
  UnsupportedCodec(Int)
  UnsupportedHash(Int)
  BadDigestLength(Int)
  TrailingBytes(Int)
}

Constructors

  • UnsupportedMultibase(prefix: String)
  • InvalidBase32
  • Truncated
  • MalformedVarint
  • UnsupportedVersion(Int)
  • UnsupportedCodec(Int)
  • UnsupportedHash(Int)
  • BadDigestLength(Int)
  • TrailingBytes(Int)
pub type Codec {
  DagCbor
  Raw
}

Constructors

  • DagCbor
  • Raw

Values

pub fn codec(cid: Cid) -> Codec
pub fn for_block(codec: Codec, block: BitArray) -> Cid

The CID of block under codec.

pub fn from_bytes(bytes: BitArray) -> Result(Cid, CidError)

Parses exactly one binary CID; trailing bytes are an error.

pub fn matches(cid: Cid, block: BitArray) -> Bool

Whether block hashes to cid.

pub fn parse(input: String) -> Result(Cid, CidError)

Parses the string form: multibase b (lowercase base32, unpadded).

pub fn take(
  bytes: BitArray,
) -> Result(#(Cid, BitArray), CidError)

Parses one binary CID off the front of bytes and returns the rest, as CAR sections need.

pub fn to_bytes(cid: Cid) -> BitArray
pub fn to_string(cid: Cid) -> String
✨ Search Document