index

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Digester

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

Digester is a simple string key value index that can be used to calculate digests of the index. The digests are cached, and only recalculated if the index has changed.

func NewDigester

func NewDigester(opts ...DigesterOption) *Digester

NewDigester returns a new digest index with an empty initialized index.

func (*Digester) Add

func (i *Digester) Add(key, value string)

Add adds the key and digest to the index.

func (*Digester) Delete

func (i *Digester) Delete(key string)

Delete removes the key from the index.

func (*Digester) Digest

func (i *Digester) Digest(a digest.Algorithm) digest.Digest

Digest returns the digest of the index using the provided algorithm. If the index has not changed since the last call to Digest, the cached digest is returned. For verifying the index against a known digest, use Verify.

func (*Digester) Get

func (i *Digester) Get(key string) string

Get returns the digest for the key, or an empty digest if the key is not found.

func (*Digester) Has

func (i *Digester) Has(key string) bool

Has returns true if the index contains the key.

func (*Digester) Index

func (i *Digester) Index() map[string]string

Index returns a copy of the index.

func (*Digester) Len

func (i *Digester) Len() int

Len returns the number of keys in the index.

func (*Digester) String

func (i *Digester) String() string

String returns a string representation of the index. The keys are stable sorted, and the string representation of the key/value pairs is written, each pair on a newline with a space between them.

func (*Digester) Verify

func (i *Digester) Verify(d digest.Digest) bool

Verify returns true if the index matches the provided digest.

func (*Digester) WriteTo

func (i *Digester) WriteTo(w io.Writer) (int64, error)

WriteTo writes the index to the writer. The keys are stable sorted, and the string representation of the key/value pairs is written, each pair on a newline with a space between them.

type DigesterOption

type DigesterOption func(*Digester)

DigesterOption is a functional option for configuring a digester.

func WithIndex

func WithIndex(i map[string]string) DigesterOption

WithIndex returns a DigesterOption that sets the index to the provided map. The map is copied, so any changes to the map after the option is applied will not be reflected in the index.

Jump to

Keyboard shortcuts

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