Documentation ¶
Index ¶
- type Digester
- func (i *Digester) Add(key, value string)
- func (i *Digester) Delete(key string)
- func (i *Digester) Digest(a digest.Algorithm) digest.Digest
- func (i *Digester) Get(key string) string
- func (i *Digester) Has(key string) bool
- func (i *Digester) Index() map[string]string
- func (i *Digester) Len() int
- func (i *Digester) String() string
- func (i *Digester) Verify(d digest.Digest) bool
- func (i *Digester) WriteTo(w io.Writer) (int64, error)
- type DigesterOption
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) 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 ¶
Get returns the digest for the key, or an empty digest if the key is not found.
func (*Digester) 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.
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.