NAME
Archive::CAR::CID - Lightweight Content Identifier (CID) for CAR archives
SYNOPSIS
use Archive::CAR::CID;
# CIDs are usually obtained via Archive::CAR
my $cid = Archive::CAR::CID->decode($file_handle);
say "Version: " . $cid->version;
say "Codec: " . $cid->codec;
say "Digest: " . unpack("H*", $cid->digest);
DESCRIPTION
Archive::CAR::CID is a minimal implementation of the Content Identifier (CID) specification, specifically tailored for use with CAR archives. It provides the necessary fields to identify data blocks without the overhead of a full Multiformats stack.
METHODS
version()
Returns the CID version (0 or 1).
codec()
Returns the IPLD codec code (e.g., 0x71 for dag-cbor).
hash()
Returns the multihash type code (e.g., 0x12 for sha2-256).
digest()
Returns the raw binary digest.
raw()
Returns the raw binary representation of the CID.
to_string()
Returns a hexadecimal string representation of the raw CID bytes (or base32 for CIDv1).
decode($fh)
Class method. Decodes a binary CID from a filehandle using standard buffered I/O.
from_raw($bytes)
Class method. Creates a CID object from a raw byte string. This is useful for CIDs obtained from external sources like firehose events.
SEE ALSO
Archive::CAR, https://github.com/multiformats/cid
AUTHOR
Sanko Robinson <sanko@cpan.org>
COPYRIGHT
Copyright (C) 2026 by Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.