scanlib

package
v0.21.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package scanlib implements a basic reachability scanner for FFS data blobs, files, and root pointers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

A Scanner scans all the blobs reachable from a collection of root and file pointers.

func NewScanner

func NewScanner(src blob.CAS) *Scanner

NewScanner creates a new empty Scanner that reads data from src.

func (*Scanner) AddBareRoot added in v0.20.15

func (s *Scanner) AddBareRoot(rootKey string, rp *root.Root)

AddBareRoot adds the specified root to the scan, including its index (if any), but excluding any blobs reachable from its file or chain pointers.

Use Scanner.ScanRoot to completely scan a root.

func (*Scanner) All

func (s *Scanner) All() iter.Seq2[string, Type]

All returns an iterator over all the key/type pairs in s.

func (*Scanner) Chunks

func (s *Scanner) Chunks(n int) iter.Seq[[]string]

Chunks returns consecutive chunks of the keys in s each having at most n elements and together spanning the complete set of keys recorded. The keys are returned in lexicographic order.

func (*Scanner) Data added in v0.13.9

func (s *Scanner) Data(key string)

Data adds the specified data blob to s.

func (*Scanner) Has added in v0.20.9

func (s *Scanner) Has(key string) bool

Has reports whether the specified key is present in s.

func (*Scanner) IsRoot

func (s *Scanner) IsRoot(key string) bool

IsRoot reports whether key is recorded as a root pointer in s.

func (*Scanner) Len

func (s *Scanner) Len() int

Len reports the total number of keys in s, of all kinds.

func (*Scanner) Remove

func (s *Scanner) Remove(key string)

Remove removes the specified key from s.

func (*Scanner) ScanFile added in v0.20.15

func (s *Scanner) ScanFile(ctx context.Context, fp *file.File) error

AddFile adds all the files and data blobs reachable from fp to s.

func (*Scanner) ScanRoot added in v0.20.15

func (s *Scanner) ScanRoot(ctx context.Context, rootKey string, rp *root.Root) error

ScanRoot adds the specified root, its index (if any), and all files reachable from its file pointer to s.

func (*Scanner) Stats

func (s *Scanner) Stats() Stats

Stats returns aggregate statistics about everything scanned in s.

func (*Scanner) Type added in v0.13.9

func (s *Scanner) Type(key string) Type

Type reports the type of the specified key. It panics if key is not in s.

type Stats

type Stats struct {
	NumRoots int // number of distinct roots
	NumFiles int // number of distinct files
	NumBlobs int // number of distinct data blobs
}

Stats records aggregate statistics about a scan.

type Type added in v0.13.9

type Type byte

Type represents the type of a blob.

const (
	Data  Type = '-' // An unstructured data blob
	File  Type = 'F' // A file record (Node)
	Root  Type = 'R' // A root record (Root)
	Index Type = 'I' // An index record (Index)
	Chain Type = 'C' // A content-addressed root (Root)
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL