Documentation
¶
Index ¶
- Constants
- Variables
- func Encode(roots []cid.Cid, blocks []Block) io.ReadCloser
- func HeaderSize(h datamodel.HeaderModel) (uint64, error)
- func Index(reader io.Reader, opts ...IndexerOption) (HeaderIndexEntry, []BlockIndexEntry, error)
- func LdRead(r *bufio.Reader) ([]byte, error)
- func LdSize(d ...[]byte) uint64
- func LdWrite(w io.Writer, d ...[]byte) error
- func ReadBlock(br *bufio.Reader) (cid.Cid, []byte, error)
- func ReadHeader(br *bufio.Reader) (datamodel.HeaderModel, error)
- func WriteBlock(w io.Writer, block Block) error
- func WriteHeader(w io.Writer, roots []cid.Cid) error
- type Block
- type BlockIndexEntry
- type BlockIndexer
- type BlockReader
- type HeaderIndexEntry
- type Indexer
- type IndexerOption
- type Reader
- type ReaderOption
- type Writer
Constants ¶
const Code = 0x0202
Code is the multicodec code for CAR files. See https://github.com/multiformats/multicodec/blob/45c88b89ab909c0fac7c86dafe43ad72d1e8e8a9/table.csv#L143
const ContentType = "application/vnd.ipld.car"
ContentType is the value the HTTP Content-Type header should have for CARs. See https://www.iana.org/assignments/media-types/application/vnd.ipld.car
Variables ¶
var MaxAllowedSectionSize uint = 32 << 20 // 32MiB
MaxAllowedSectionSize dictates the maximum number of bytes that a CARv1 header or block is allowed to occupy without causing a decode to error.
Functions ¶
func Encode ¶
func Encode(roots []cid.Cid, blocks []Block) io.ReadCloser
Encode takes a list of root CIDs and blocks, and produces an io.ReadCloser that emits the bytes of a CAR file containing those roots and blocks. The caller should call Close on the returned ReadCloser when finished to free up resources.
func HeaderSize ¶
func HeaderSize(h datamodel.HeaderModel) (uint64, error)
func Index ¶
func Index(reader io.Reader, opts ...IndexerOption) (HeaderIndexEntry, []BlockIndexEntry, error)
Index reads through a CAR file and returns the byte offsets of each block along with its CID, without loading the block data into memory.
func ReadHeader ¶
func ReadHeader(br *bufio.Reader) (datamodel.HeaderModel, error)
Types ¶
type BlockIndexer ¶
BlockIndexer is a helper for iterating through blocks in a CAR file while keeping track of their byte offsets for indexing purposes.
func (*BlockIndexer) Read ¶
func (bi *BlockIndexer) Read() (BlockIndexEntry, error)
type BlockReader ¶
BlockReader is a helper for iterating through blocks in a CAR file.
func (*BlockReader) Read ¶
func (r *BlockReader) Read() (Block, error)
type HeaderIndexEntry ¶
type Indexer ¶
type Indexer struct {
Header HeaderIndexEntry
// contains filtered or unexported fields
}
func NewIndexer ¶
func NewIndexer(r io.Reader, opts ...IndexerOption) (*Indexer, error)
func (*Indexer) Read ¶
func (r *Indexer) Read() (BlockIndexEntry, error)
type IndexerOption ¶
type IndexerOption func(*indexerCfg)
func WithIndexerSkipIntegrityChecks ¶
func WithIndexerSkipIntegrityChecks() IndexerOption
WithIndexSkipIntegrityChecks configures the indexer to skip integrity checks when reading blocks. This can be used to speed up indexing when the integrity of the blocks is not a concern.
type Reader ¶
type Reader struct {
Header datamodel.HeaderModel
// contains filtered or unexported fields
}
type ReaderOption ¶
type ReaderOption func(*readerCfg)
func WithSkipIntegrityChecks ¶
func WithSkipIntegrityChecks() ReaderOption
WithSkipIntegrityChecks configures the reader to skip integrity checks when reading blocks. This can be used to speed up decoding when the integrity of the blocks is not a concern.