atproto_repo/car

CAR v1 reading. Every block is hashed and checked against the CID its section claims, so a Car never holds a block under a CID it does not match. Block order, duplicates and unreferenced blocks are all accepted.

Types

pub type Car {
  Car(roots: List(cid.Cid), blocks: dict.Dict(cid.Cid, BitArray))
}

Constructors

pub type CarError {
  CarTooLarge(limit: Int, observed: Int)
  HeaderTooLarge(limit: Int, observed: Int)
  TooManyBlocks(limit: Int, observed: Int)
  BlockTooLarge(index: Int, limit: Int, observed: Int)
  BadHeaderLength
  TruncatedHeader
  HeaderDecode(dag_cbor.DecodeError)
  HeaderShape(field: String)
  UnsupportedVersion(Int)
  BadSectionLength(index: Int)
  TruncatedSection(index: Int)
  BadSectionCid(index: Int, error: cid.CidError)
  BlockMismatch(index: Int, claimed: cid.Cid)
}

Constructors

  • CarTooLarge(limit: Int, observed: Int)
  • HeaderTooLarge(limit: Int, observed: Int)
  • TooManyBlocks(limit: Int, observed: Int)
  • BlockTooLarge(index: Int, limit: Int, observed: Int)
  • BadHeaderLength
  • TruncatedHeader
  • HeaderDecode(dag_cbor.DecodeError)
  • HeaderShape(field: String)
  • UnsupportedVersion(Int)
  • BadSectionLength(index: Int)
  • TruncatedSection(index: Int)
  • BadSectionCid(index: Int, error: cid.CidError)
  • BlockMismatch(index: Int, claimed: cid.Cid)

Values

pub fn read(input: BitArray) -> Result(Car, CarError)

Reads with limits.default().

pub fn read_with(
  input: BitArray,
  limits: limits.Limits,
) -> Result(Car, CarError)

Sizes are checked before the thing they bound is sliced, hashed or decoded: the whole input first, then the header and each block.

✨ Search Document