tree

package
v0.0.0-...-5abfbfe Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package tree implements a in-memory tree / node structure to store and retrieve resource record data

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNodeNotFound       = errors.New("node not found in tree")
	ErrNoSuchData         = errors.New("no such data")
	ErrChildAlreadyExists = errors.New("child already exists")
)

Functions

This section is empty.

Types

type Node

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

func (*Node) AddChild

func (n *Node) AddChild(name string, child Node) error

AddChild adds a child to this node or returns an error if the child already exists

func (*Node) AddRecords

func (n *Node) AddRecords(records []rr.RR)

AddRecords adds records to this node

func (*Node) Child

func (n *Node) Child(name string) (Node, error)

Child returns this node's child identified by 'name" or an error if this child doesn't exist

func (*Node) Parent

func (n *Node) Parent() *Node

Parent returns this node's parent node

func (*Node) Records

func (n *Node) Records(class, t uint16) ([]rr.RR, error)

Record returns a stored record with class and type

type Tree

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

Tree describes a tree structure which stores data for DNS labels

func New

func New() *Tree

func (*Tree) Get

func (t *Tree) Get(name string) (Node, error)

Get retrieves a node via a name. Example: example.com traverses the tree like . -> com -> example

func (*Tree) Populate

func (t *Tree) Populate(name string) (Node, error)

Populate traverses the tree and adds nodes along the path which don't exist yet

func (*Tree) Walk

func (t *Tree) Walk(name string) (Node, error)

Walk traverses the tree until the end of labels is reached

func (*Tree) WalkChain

func (t *Tree) WalkChain(name string) ([]Node, error)

WalkChain traverses the tree until the end of labels is reached which returns a list of nodes

Jump to

Keyboard shortcuts

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