lpm

package
v0.9.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeLPMKey

func EncodeLPMKey(data []byte, prefixLen PrefixLen) (index.Key, error)

EncodeLPMKey encodes data and its prefix length as an LPM index key. It returns an error if data does not contain enough bits for prefixLen.

func NetIPPrefix4ToIndexKey

func NetIPPrefix4ToIndexKey(prefix netip.Prefix) index.Key

func NetIPPrefixToIndexKey

func NetIPPrefixToIndexKey(prefix netip.Prefix) index.Key

NetIPPrefixToIndexKey encodes prefix as an LPM index key. IPv4-mapped IPv6 prefixes contained in ::ffff:0:0/96 are canonicalized to IPv4.

Types

type Iterator

type Iterator[T any] struct {
	// contains filtered or unexported fields
}

func (*Iterator[T]) All

func (it *Iterator[T]) All(yield func([]byte, T) bool)

func (*Iterator[T]) Next

func (it *Iterator[T]) Next() (key []byte, value T, ok bool)

type PrefixLen

type PrefixLen = uint16

func DecodeLPMKey

func DecodeLPMKey(key index.Key) (data []byte, prefixLen PrefixLen)

type Trie

type Trie[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any]() Trie[T]

func (*Trie[T]) All

func (l *Trie[T]) All() *Iterator[T]

func (*Trie[T]) Len

func (l *Trie[T]) Len() int

func (*Trie[T]) Lookup

func (l *Trie[T]) Lookup(key index.Key) (value T, found bool)

func (*Trie[T]) LookupExact

func (l *Trie[T]) LookupExact(key index.Key) (value T, found bool)

func (*Trie[T]) LowerBound

func (l *Trie[T]) LowerBound(key index.Key) *Iterator[T]

func (*Trie[T]) Prefix

func (l *Trie[T]) Prefix(key index.Key) *Iterator[T]

func (*Trie[T]) Print

func (l *Trie[T]) Print()

func (*Trie[T]) Txn

func (l *Trie[T]) Txn() *Txn[T]

type Txn

type Txn[T any] struct {
	// contains filtered or unexported fields
}

func (*Txn[T]) All

func (txn *Txn[T]) All() *Iterator[T]

func (*Txn[T]) Clear

func (txn *Txn[T]) Clear()

Clear the transaction for reuse.

func (*Txn[T]) Commit

func (txn *Txn[T]) Commit() Trie[T]

func (*Txn[T]) Delete

func (txn *Txn[T]) Delete(key index.Key) (value T, found bool)

func (*Txn[T]) Insert

func (txn *Txn[T]) Insert(key index.Key, value T) error

func (*Txn[T]) Len

func (txn *Txn[T]) Len() int

func (*Txn[T]) Lookup

func (txn *Txn[T]) Lookup(key index.Key) (value T, found bool)

func (*Txn[T]) LookupExact

func (txn *Txn[T]) LookupExact(key index.Key) (value T, found bool)

func (*Txn[T]) LowerBound

func (txn *Txn[T]) LowerBound(key index.Key) *Iterator[T]

func (*Txn[T]) Prefix

func (txn *Txn[T]) Prefix(key index.Key) *Iterator[T]

func (*Txn[T]) Reuse

func (txn *Txn[T]) Reuse(trie Trie[T]) *Txn[T]

Jump to

Keyboard shortcuts

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