ipldutil

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT, Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeNode

func DecodeNode(encoded []byte) (ipld.Node, error)

func EncodeNode

func EncodeNode(node ipld.Node) ([]byte, error)

func ParseSelector

func ParseSelector(selector ipld.Node) (selector.Selector, error)

func WalkMatching

func WalkMatching(node ipld.Node, s selector.Selector, fn traversal.VisitFn) error

Types

type ContextCancelError

type ContextCancelError struct{}

ContextCancelError is a sentinel that indicates the passed in context was cancelled

func (ContextCancelError) Error

func (cp ContextCancelError) Error() string

type TraversalBuilder

type TraversalBuilder struct {
	Root     ipld.Link
	Selector ipld.Node
	Visitor  traversal.AdvVisitFn
	Chooser  traversal.LinkTargetNodePrototypeChooser
}

TraversalBuilder defines parameters for an iterative traversal

func (TraversalBuilder) Start

func (tb TraversalBuilder) Start(parentCtx context.Context) Traverser

Start initiates the traversal (run in a go routine because the regular selector traversal expects a call back)

type Traverser

type Traverser interface {
	// IsComplete returns the completion state (boolean) and if so, the final error result from IPLD
	IsComplete() (bool, error)
	// Current request returns the current link waiting to be loaded
	CurrentRequest() (ipld.Link, ipld.LinkContext)
	// Advance advances the traversal successfully by supplying the given reader as the result of the next IPLD load
	Advance(reader io.Reader) error
	// Error errors the traversal by returning the given error as the result of the next IPLD load
	Error(err error)
	// Shutdown cancels the traversal
	Shutdown(ctx context.Context)
}

Traverser is an interface for performing a selector traversal that operates iteratively -- it stops and waits for a manual load every time a block boundary is encountered

Jump to

Keyboard shortcuts

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