namer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package namer represent interface to templates creation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultKey

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

DefaultKey implements default realization.

func NewDefaultKey

func NewDefaultKey(name string, keytype KeyType, property string, raw string) DefaultKey

NewDefaultKey returns new Key object.

func (DefaultKey) Build

func (k DefaultKey) Build() string

Build reconstructs key string.

func (DefaultKey) Name

func (k DefaultKey) Name() string

Name returns name of the key.

func (DefaultKey) Property

func (k DefaultKey) Property() string

Property returns property of the key.

func (DefaultKey) Type

func (k DefaultKey) Type() KeyType

Type returns type of the key.

type DefaultNamer

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

DefaultNamer represents default namer.

func (*DefaultNamer) GenerateNames

func (n *DefaultNamer) GenerateNames(name string) ([]Key, error)

GenerateNames all keys for an object name.

func (*DefaultNamer) ParseKey

func (n *DefaultNamer) ParseKey(name string) (DefaultKey, error)

ParseKey parses a raw key name into a structured DefaultKey.

func (*DefaultNamer) ParseKeys

func (n *DefaultNamer) ParseKeys(names []string, ignoreError bool) (Results, error)

ParseKeys combine multiple raw keys into grouped results.

func (*DefaultNamer) Prefix

func (n *DefaultNamer) Prefix(val string, isPrefix bool) string

Prefix returns the prefix used by this namer.

type InvalidKeyError

type InvalidKeyError struct {
	Key     string
	Problem string
}

InvalidKeyError represents an error for invalid key format.

func (InvalidKeyError) Error

func (e InvalidKeyError) Error() string

type InvalidNameError

type InvalidNameError struct {
	Name    string
	Problem string
}

InvalidNameError represents an error for invalid name format.

func (InvalidNameError) Error

func (e InvalidNameError) Error() string

type Key

type Key interface {
	Name() string     // Get object name.
	Type() KeyType    // Get key type.
	Property() string // Get metadata (e.g., algorithm version).
	Build() string    // Reconstruct raw key string.
}

Key defines the minimal interface required by keys.

type KeyType

type KeyType int

KeyType represents key types.

const (
	// KeyTypeValue represents data type.
	KeyTypeValue KeyType = iota + 1
	// KeyTypeHash represents hash of the data type.
	KeyTypeHash
	// KeyTypeSignature represents signature of the data type.
	KeyTypeSignature
)

func (KeyType) String

func (t KeyType) String() string

type Namer

type Namer interface {
	GenerateNames(name string) ([]Key, error)
	ParseKey(name string) (DefaultKey, error)
	ParseKeys(names []string, ignoreError bool) (Results, error)
	Prefix(val string, isPrefix bool) string
}

Namer defines the interface for generating and parsing storage key names.

func NewDefaultNamer

func NewDefaultNamer(prefix string, hashNames []string, sigNames []string) Namer

NewDefaultNamer returns new DefaultNamer object with hash/signature names configuration.

type Results

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

Results represents Namer working result.

func NewResults

func NewResults(initial map[string][]Key) Results

NewResults creates a new Results instance from the provided initial data.

func (*Results) Items

func (r *Results) Items() iter.Seq2[string, []Key]

Items return iterator over all name->keys groups.

func (*Results) Len

func (r *Results) Len() int

Len returns the number of unique object names.

func (*Results) Result

func (r *Results) Result() map[string][]Key

Result returns the underlying results map.

func (*Results) Select

func (r *Results) Select(name string) ([]Key, bool)

Select gets keys for a specific object name.

func (*Results) SelectSingle

func (r *Results) SelectSingle() ([]Key, bool)

SelectSingle gets keys for single-name case (if applicable).

Jump to

Keyboard shortcuts

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