anchor

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anchor

type Anchor api.Anchor

func (Anchor) AddRef

func (a Anchor) AddRef() Anchor

func (Anchor) Ls

func (a Anchor) Ls(ctx context.Context) (*Iterator, capnp.ReleaseFunc)

func (Anchor) Release

func (a Anchor) Release()

func (Anchor) Walk

func (a Anchor) Walk(ctx context.Context, path string) (Anchor, capnp.ReleaseFunc)

Walk to the register located at path.

type Iterator

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

func (*Iterator) Anchor

func (it *Iterator) Anchor() Anchor

func (*Iterator) Err

func (it *Iterator) Err() error

func (*Iterator) Next

func (it *Iterator) Next() (name string)

Next returns the name of the next subanchor in the stream. It returns an empty string when the iterator has been exhausted.

type Node

type Node struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Node) AddRef

func (n *Node) AddRef() *Node

func (*Node) Anchor

func (n *Node) Anchor() Anchor

func (*Node) Child

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

Child returns the named child of the current node, creating it if it does not exist.

func (*Node) Release

func (n *Node) Release()

type Path

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

Path represents the location of an anchor. It is a bounded value that enforces the following constraints: paths are strings that MAY contain any printable ASCII characters except the backslash. The forward slash '/' separates path components.

All paths are relative; there is no way of referencing a parent anchor from its child. This provides a form of capability-based isolation wherein principals are limited to the scope of anchor references in their possession.

A path comprising a single '/' is the "root" path. The root path designates the current anchor. Equivalently, it can be said that the root path is the identity function over anchors, or that the Anchor.Walk() method is a nop when the root path is passed in as an argument. The empty string automatically resolves to the root path. Zero-value paths are also treated as root, but are used as as a safe default when the path contains an error, and therefore are NOT RECOMMENDED.

func JoinPath

func JoinPath(parts []string) Path

JoinPath joins each element of 'parts' into a single path, with each element separated by '/'. Each element of 'parts' is validated before being joined. An element is valid if it is a valid path, and does not contain the path separator.

Callers SHOULD check Path.Err() before proceeding.

func NewPath

func NewPath(path string) (p Path)

NewPath returns a new Path value, containing a canonical path if the 'path' argument is valid, or an error if it is not.

Callers SHOULD check Path.Err() before proceeding.

func (Path) Err

func (p Path) Err() error

Err returns a non-nil error if the path is malformed.

func (Path) Next

func (p Path) Next() (Path, string)

Next splits the path into the tail and head components. It is used to iterate through each path component sequentially, using the following pattern:

for path, name := path.Next(); name != ""; path, name = path.Next() {
    // do something...
}

func (Path) String

func (p Path) String() string

String returns the canonical path string. If Err() != nil, String() returns the zero-value string.

Jump to

Keyboard shortcuts

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