CID decoder

class atproto_core.cid.CID(version: int | None = None, codec: int | None = None, hash: Multihash | None = None, _stringified_form: str | None = None, _raw_byte_form: bytes | None = None)

Bases: object

Content Identifier.

Note

version, codec, and hash are decoded lazily on first access. Consumers that only compare or stringify CIDs (the CAR decoding path, for one) never pay for the multihash.

classmethod decode(value: str | bytes) CID
classmethod from_decoded_bytes(value: bytes) CID

Wrap the binary form of a CID that the decoder it came from has already validated.

Skips the redundant libipld.decode_cid call that CID.decode performs.

property version: int

Get CID version.

property codec: int

Get CID codec.

property hash: Multihash

Get CID multihash.

encode() str
type CIDType

A atproto_core.cid.CID that pydantic can validate and serialise. Accepts the string form on the wire.

class atproto_core.cid.cid.Multihash(code: int, size: int, digest: bytes)

Bases: object

code: int
size: int
digest: bytes