ProtoRune.CAR (proto_rune v0.5.2)

Copy Markdown

Reader for CAR (Content Addressable aRchive) v1 data.

Commit events delivered by the ATProto firehose carry their repository blocks as a CAR byte string in the blocks field. A CAR is a sequence of varint-length-prefixed segments: a CBOR header with the root CIDs, followed by entries pairing a binary CID with its block data.

Summary

Types

t()

A parsed CAR: the root CIDs and the ordered CID/block entries.

Functions

Parses CAR data, returning its roots and blocks.

Types

t()

@type t() :: %{roots: [ProtoRune.CID.t()], blocks: [{ProtoRune.CID.t(), binary()}]}

A parsed CAR: the root CIDs and the ordered CID/block entries.

Functions

read(data)

@spec read(binary()) :: {:ok, t()} | {:error, atom() | tuple()}

Parses CAR data, returning its roots and blocks.

Blocks are returned as {cid, block_bytes} tuples in archive order; the block bytes are the raw DAG-CBOR data, decodable with ProtoRune.CBOR.