Versions in this module Expand all Collapse all v2 v2.5.6 Nov 15, 2026 Changes in this version + const BundleMagic + const ChunkingFastCDCV1 + const ChunkingKey + const DefaultMaxChanges + const DefaultMaxWrittenEntries + const FastCDCGearSeedPrefix + const FastCDCLooseMask + const FastCDCMaxSize + const FastCDCMinSize + const FastCDCStrictMask + const FastCDCTargetSize + const ListItemBytes + const MaxCarriedNodes + const MaxChunkBytes + const MaxEntryBytes + const MaxExtraBytes + const MaxExtraNameBytes + const MaxExtraValueBytes + const MaxExtraValues + const MaxFolderDepth + const MaxListItems + const MaxNameBytes + const MaxRecordBytes + const MaxRequestBytes + const RequestsAheadBytes + const TimestampKey + const Version + var ErrCorrupt = &Error + var ErrHashMismatch = &Error + var ErrIO = &Error + var ErrIntakeFailed = &Error + var ErrInvalidBase32 = &Error + var ErrInvalidData = &Error + var ErrInvalidHex = &Error + var ErrInvalidName = &Error + var ErrInvalidRoot = &Error + var ErrInvariant = &Error + var ErrLimitExceeded = &Error + var ErrMissing = &Error + var ErrNonUTF8FileName = &Error + var ErrNotWanted = &Error + var ErrPeer = &Error + var ErrSizeMismatch = &Error + var ErrSizeOverflow = &Error + var ErrStream = &Error + var ErrSystemTimeBeforeUnixEpoch = &Error + var ErrTooDeep = &Error + var ErrTotalsMismatch = &Error + var ErrUnsupportedEntry = &Error + var ErrUnwritableName = &Error + var FastCDCV1 = Chunking + func CheckName(name string) error + func ChunkFrame(chunk []byte) []byte + func Export(store Store, root Root, out io.Writer) error + func FileBranchFrame(branch *FileBranch) []byte + func FileListFrame(list []byte) []byte + func FolderBranchFrame(branch *FolderBranch) []byte + func FolderListFrame(list []byte) []byte + func HaveFrame(held *HaveMap) []byte + func ReadFile(store Store, file Target, out io.Writer) error + func ReadFileBytes(store Store, file Target) ([]byte, error) + func ReadFrame(input io.Reader, limit int) ([]byte, error) + func ReadOpen(store Store, file *OpenFile, offset, length uint64, out io.Writer) error + func ReadRange(store Store, file Target, offset, length uint64, out io.Writer) error + func RefusedFrame(why Refusal) []byte + func Serve(store Store, from io.Reader, output io.Writer) error + func Unwritable(name string) (reason string, unwritable bool) + func UnwritableOnWindows(name string) (reason string, unwritable bool) + func WriteFrame(out io.Writer, frame []byte) error + func WriteToDisk(store Store, root Root, dest string) error + func WriteToDiskWith(store Store, root Root, dest string, options WriteOptions) error + type Accepted struct + Kept bool + What Arrived + type Arrived struct + Hash Hash + Kind ArrivedKind + type ArrivedKind uint8 + const ArrivedChunk + const ArrivedFileList + const ArrivedFolderList + const ArrivedRecord + type Asked struct + Limit int + Request []byte + type BuildOptions struct + Chunking Chunking + Extra ExtraData + Links Links + Timestamp bool + Workers int + type Builder struct + func NewBuilder(store Store, chunking Chunking) *Builder + func (b *Builder) Chunking() Chunking + func (b *Builder) File(reader io.Reader) (Target, error) + func (b *Builder) FileAt(path string) (Target, error) + func (b *Builder) FileFromBytes(content []byte) (Target, error) + func (b *Builder) Finish(top Target, extra ExtraData) (Root, error) + func (b *Builder) Folder(entries []Entry) (Target, error) + func (b *Builder) Threads(threads int) *Builder + type Change struct + Kind ChangeKind + New Entry + Old Entry + Path string + func Diff(store Store, old, new Root) ([]Change, error) + func DiffWithin(store Store, old, new Root, most int) ([]Change, error) + type ChangeKind uint8 + const ChangeAdded + const ChangeChanged + const ChangeRemoved + func (k ChangeKind) String() string + type ChunkRef struct + Hash Hash + Length uint32 + func ChunkRefOf(bytes []byte) (ChunkRef, error) + func (p ChunkRef) Matches(bytes []byte) bool + type Chunking struct + func ChunkingFromTag(tag []byte) (Chunking, error) + func FixedChunking(size uint32) (Chunking, error) + func (c Chunking) CheckCount(size, count uint64) error + func (c Chunking) CheckLength(length uint32, isLast bool) error + func (c Chunking) CountBounds(size uint64) (fewest, most uint64) + func (c Chunking) Cut(data []byte) [][]byte + func (c Chunking) Fixed() (size uint32, fixed bool) + func (c Chunking) String() string + func (c Chunking) Tag() string + type Entries struct + Entries []Entry + Start uint64 + Total uint64 + type Entry struct + func Lookup(store Store, root Root, path string) (Entry, bool, error) + func NewEntry(name string, target Target, extra ExtraData) (Entry, error) + func (e Entry) EncodedLen() int + func (e Entry) Equal(other Entry) bool + func (e Entry) Extra() ExtraData + func (e Entry) Hash() Hash + func (e Entry) Kind() Kind + func (e Entry) Name() string + func (e Entry) Size() uint64 + func (e Entry) Target() Target + type EntryExtra func(path, name string, kind Kind) (ExtraData, error) + type Error struct + Actual uint64 + Detail string + Err error + Expected uint64 + Hash Hash + Limit uint64 + Name string + Operation string + Path string + Reason string + Requested uint64 + What string + func (e *Error) Error() string + func (e *Error) Is(target error) bool + func (e *Error) Unwrap() error + type ExtraData struct + func (e ExtraData) All() iter.Seq2[string, []byte] + func (e ExtraData) Equal(other ExtraData) bool + func (e ExtraData) Get(name string) ([]byte, bool) + func (e ExtraData) Len() int + func (e ExtraData) Text(name string) (string, bool) + func (e ExtraData) With(name string, value []byte) (ExtraData, error) + func (e ExtraData) WithText(name, value string) (ExtraData, error) + func (e ExtraData) Without(name string) ExtraData + type FileBranch struct + func DecodeFileBranch(bytes []byte) (*FileBranch, error) + func (r *FileBranch) Check(file Target) (uint64, error) + func (r *FileBranch) CheckWithChunking(file Target, chunking Chunking) (uint64, error) + func (r *FileBranch) Count() uint64 + func (r *FileBranch) Encode() []byte + func (r *FileBranch) Items() []ChunkRef + func (r *FileBranch) Start() uint64 + type FileList struct + func DecodeFileList(bytes []byte) (*FileList, error) + func FileOf(store Store, file Target) (*FileList, error) + func NewFileList(items []ChunkRef) (*FileList, error) + func (l *FileList) CheckChunking(chunking Chunking) error + func (l *FileList) Count() uint64 + func (l *FileList) Encode() []byte + func (l *FileList) EncodedLen() uint64 + func (l *FileList) Hash() Hash + func (l *FileList) Items() []ChunkRef + func (l *FileList) Open(start, end uint64) (*FileBranch, error) + func (l *FileList) Size() uint64 + func (l *FileList) Target() Target + type FolderBranch struct + func DecodeFolderBranch(bytes []byte) (*FolderBranch, error) + func (r *FolderBranch) Check(folder Target) error + func (r *FolderBranch) CheckName(folder Target, name string) (Entry, bool, error) + func (r *FolderBranch) Count() uint64 + func (r *FolderBranch) Encode() []byte + func (r *FolderBranch) Entries() []Entry + func (r *FolderBranch) Start() uint64 + type FolderList struct + func DecodeFolderList(bytes []byte) (*FolderList, error) + func FolderOf(store Store, folder Target) (*FolderList, error) + func NewFolderList(entries []Entry) (*FolderList, error) + func (l *FolderList) Count() uint64 + func (l *FolderList) Encode() []byte + func (l *FolderList) EncodedLen() uint64 + func (l *FolderList) Entries() []Entry + func (l *FolderList) Get(name string) (Entry, bool) + func (l *FolderList) Hash() Hash + func (l *FolderList) Open(start, end uint64) (*FolderBranch, error) + func (l *FolderList) OpenName(name string) (*FolderBranch, error) + func (l *FolderList) PlaceOf(name string) (uint64, bool) + func (l *FolderList) Size() uint64 + func (l *FolderList) Target() Target + type Frame struct + Bytes []byte + FileBranch *FileBranch + FolderBranch *FolderBranch + Have *HaveMap + Kind FrameKind + Refusal Refusal + func DecodeFrame(bytes []byte) (Frame, error) + type FrameKind uint8 + const FrameChunk + const FrameFileBranch + const FrameFileList + const FrameFolderBranch + const FrameFolderList + const FrameHave + const FrameRecord + const FrameRefused + type Hash [32]byte + func FileHash(count, size uint64, list Hash) Hash + func FolderHash(count, size uint64, list Hash) Hash + func HashFromHex(text string) (Hash, error) + func HashFromSlice(bytes []byte) (Hash, error) + func HashOf(bytes []byte) Hash + func (h Hash) Hex() string + func (h Hash) IsZero() bool + func (h Hash) String() string + type HaveMap struct + func DecodeHaveMap(bytes []byte) (*HaveMap, error) + func NewHaveMap(count uint64) (*HaveMap, error) + func (m *HaveMap) Count() uint64 + func (m *HaveMap) Encode() []byte + func (m *HaveMap) Get(index uint64) bool + func (m *HaveMap) Held() uint64 + func (m *HaveMap) Set(index uint64) error + type Intake struct + func NewIntake(store Store, root Root) (*Intake, error) + func (i *Intake) Accept(frame []byte) (Accepted, error) + func (i *Intake) AcceptExpected(frame []byte, expected Arrived) (Accepted, error) + func (i *Intake) AnswerLimit(request Request) int + func (i *Intake) Expected(request Request) []Arrived + func (i *Intake) Finish() (*Summary, error) + func (i *Intake) FrameLimit() int + func (i *Intake) Outstanding() int + func (i *Intake) Record() *Record + func (i *Intake) Requests(limit int) []Request + func (i *Intake) Root() Root + type Kind uint8 + const KindFile + const KindFolder + func (k Kind) String() string + type Links uint8 + const LinksRefuse + const LinksSkip + type MemoryStore struct + func NewMemoryStore() *MemoryStore + func (s *MemoryStore) Bytes(kind Stored) uint64 + func (s *MemoryStore) Count(kind Stored) int + func (s *MemoryStore) Get(kind Stored, hash Hash) ([]byte, bool, error) + func (s *MemoryStore) Has(kind Stored, hash Hash) (bool, error) + func (s *MemoryStore) Hashes(kind Stored) []Hash + func (s *MemoryStore) Put(kind Stored, hash Hash, content []byte) error + func (s *MemoryStore) Remove(kind Stored, hash Hash) error + func (s *MemoryStore) Size(kind Stored, hash Hash) (uint64, bool, error) + type OpenFile struct + func DecodeOpenFile(bytes []byte) (*OpenFile, error) + func NewOpenFile(list *FileList) (*OpenFile, error) + func (f *OpenFile) ChunksFor(offset, length uint64) (first, after uint64, err error) + func (f *OpenFile) List() *FileList + func (f *OpenFile) Open(start, end uint64) (*FileBranch, error) + func (f *OpenFile) OpenBytes(offset, length uint64) (*FileBranch, error) + func (f *OpenFile) StartOf(index uint64) (uint64, bool) + type OpenFolder struct + func DecodeOpenFolder(bytes []byte) (*OpenFolder, error) + func NewOpenFolder(list *FolderList) (*OpenFolder, error) + func (f *OpenFolder) List() *FolderList + func (f *OpenFolder) Open(start, end uint64) (*FolderBranch, error) + func (f *OpenFolder) OpenName(name string) (*FolderBranch, error) + type Peer interface + Ask func(request []byte, limit int, onFrame func(frame []byte) error) error + type PeerAskAll interface + AskAll func(requests []Asked, onFrame func(place int, frame []byte) error) error + type Record struct + func DecodeRecord(bytes []byte) (*Record, error) + func NewRecord(top Target, totals Totals, chunking Chunking, extra ExtraData) (*Record, error) + func RecordOf(store Store, root Root) (*Record, error) + func (r *Record) Chunking() Chunking + func (r *Record) Encode() []byte + func (r *Record) Extra() ExtraData + func (r *Record) Root() Root + func (r *Record) Top() Target + func (r *Record) Totals() Totals + type Refusal uint8 + const RefusalNotHeld + const RefusalOutOfRange + func (r Refusal) String() string + type Remote struct + func OpenRemote(peer Peer, root Root) (*Remote, error) + func (r *Remote) Entries(folder Target, start uint64, count uint32) (*Entries, error) + func (r *Remote) Entry(folder Target, name string) (Entry, bool, error) + func (r *Remote) Have(file Target) (*HaveMap, error) + func (r *Remote) Lookup(path string) (Entry, bool, error) + func (r *Remote) Read(file Target, offset, length uint64, out io.Writer) error + func (r *Remote) Record() *Record + func (r *Remote) Root() Root + type Request struct + Count uint32 + Hash Hash + Kind RequestKind + Length uint64 + Name string + Offset uint64 + Start uint64 + func DecodeRequest(bytes []byte) (Request, error) + func RequestChunk(chunk Hash) Request + func RequestChunks(file Hash, start uint64, count uint32) Request + func RequestFile(file Hash) Request + func RequestFileBranch(file Hash, start uint64, count uint32) Request + func RequestFileBytes(file Hash, offset, length uint64) Request + func RequestFolder(folder Hash) Request + func RequestFolderBranch(folder Hash, start uint64, count uint32) Request + func RequestFolderName(folder Hash, name string) Request + func RequestHave(file Hash) Request + func RequestRecord(root Root) Request + func (r Request) Encode() []byte + type RequestKind uint8 + const AskChunk + const AskChunks + const AskFile + const AskFileBranch + const AskFileBytes + const AskFolder + const AskFolderBranch + const AskFolderName + const AskHave + const AskRecord + type Responder struct + func NewResponder(store Store) *Responder + func (r *Responder) Answer(request []byte, onFrame func(frame []byte) error) error + func (r *Responder) Ask(request []byte, limit int, onFrame func(frame []byte) error) error + func (r *Responder) Have(on bool) *Responder + func (r *Responder) Recent(items uint64) *Responder + type Root Hash + func Build(store Store, path string, options BuildOptions) (Root, error) + func BuildWith(store Store, path string, options BuildOptions, entryExtra EntryExtra) (Root, error) + func ParseRoot(text string) (Root, error) + func RootOfRecord(record []byte) Root + func (r Root) Hash() Hash + func (r Root) String() string + type Store interface + Get func(kind Stored, hash Hash) ([]byte, bool, error) + Put func(kind Stored, hash Hash, bytes []byte) error + Remove func(kind Stored, hash Hash) error + type StoreHas interface + Has func(kind Stored, hash Hash) (bool, error) + type StoreLend interface + Lend func(kind Stored, hash Hash, with func(bytes []byte) error) (bool, error) + type StoreSize interface + Size func(kind Stored, hash Hash) (uint64, bool, error) + type Stored uint8 + const StoredChunk + const StoredFileList + const StoredFolderList + const StoredRecord + func (s Stored) String() string + type StreamPeer struct + func NewStreamPeer(input io.Reader, output io.Writer) *StreamPeer + func (p *StreamPeer) Ahead(bytes int) *StreamPeer + func (p *StreamPeer) Ask(request []byte, limit int, onFrame func(frame []byte) error) error + func (p *StreamPeer) AskAll(requests []Asked, onFrame func(place int, frame []byte) error) error + type Summary struct + Files uint64 + Folders uint64 + Record *Record + func Fetch(store Store, root Root, peer Peer) (*Summary, error) + func Import(store Store, root Root, from io.Reader) (*Summary, error) + func Verify(store Store, root Root) (*Summary, error) + func VerifyWith(store Store, root Root, options VerifyOptions) (*Summary, error) + type Target struct + Hash Hash + Kind Kind + Size uint64 + type Totals struct + ChunkBytes uint64 + Chunks uint64 + ListBytes uint64 + type VerifyOptions struct + DiscardDamaged bool + Rechunk bool + Workers int + type WorkerPanic struct + Stack []byte + Value any + func (p *WorkerPanic) Error() string + func (p *WorkerPanic) Unwrap() error + type WriteOptions struct + MaxBytes uint64 + MaxEntries uint64