Documentation
¶
Index ¶
- type Pair
- type Storage
- func (s *Storage) Add(key, value string) *Storage
- func (s *Storage) Clear() *Storage
- func (s *Storage) Clone() *Storage
- func (s *Storage) Delete(key string) *Storage
- func (s *Storage) Empty() bool
- func (s *Storage) Expose() []Pair
- func (s *Storage) Has(key string) bool
- func (s *Storage) Keys() iter.Seq[string]
- func (s *Storage) Len() int
- func (s *Storage) Lookup(key string) (value string, found bool)
- func (s *Storage) Pairs() iter.Seq2[string, string]
- func (s *Storage) Set(key, value string) *Storage
- func (s *Storage) Value(key string) string
- func (s *Storage) ValueOr(key, otherwise string) string
- func (s *Storage) Values(key string) iter.Seq[string]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is an associative structure for storing (string, string) pairs. It acts as a map but uses linear search instead, which proves to be more efficient on relatively low amount of entries, which often enough is the case.
func NewFromMap ¶
NewFromMap returns a new instance with already inserted values from given map. Note: as maps are unordered, resulting underlying structure will also contain unordered pairs.
func NewFromPairs ¶ added in v0.17.2
NewFromPairs returns a new instance backed by the passed pairs as-is, without copying it. Use this method with care.
func NewPrealloc ¶
NewPrealloc returns an instance of Storage with pre-allocated underlying storage.
func (*Storage) Clone ¶
Clone creates a deep copy, which may be used later or stored somewhere safely. However, it comes at cost of multiple allocations.
func (*Storage) Delete ¶ added in v0.17.2
Delete quasi removes all the entries corresponding the key. In fact, an empty key is assigned to each eligible pair.
func (*Storage) Expose ¶
Expose exposes the underlying pairs slice. Unlike Pairs, it also contains all the deleted empty-key pairs
func (*Storage) Lookup ¶ added in v0.17.2
Lookup returns the first found value and indicates the success via a bool flag.
func (*Storage) Pairs ¶ added in v0.17.2
Pairs return an iterator over all the header field pairs presented. Multiple values are represented by occupying multiple pairs sharing the same key. Array values can occupy non-consecutive pairs.
func (*Storage) Set ¶ added in v0.17.2
Set removes all the entries corresponding the key and sets the new value.
func (*Storage) Value ¶
Value returns the first value, corresponding to the key. Otherwise, empty string is returned