ipldlegacy

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: Apache-2.0, MIT Imports: 14 Imported by: 24

README

Go-ipld-legacy

A compatibility layer between go-ipld-prime and go-ipld-format

Lead Maintainer

Hannah Howard

Contributing

Contributions are welcome! This repository is part of the IPFS project and therefore governed by our contributing guidelines.

License

SPDX-License-Identifier: Apache-2.0 OR MIT

Documentation

Index

Constants

View Source
const (
	// ErrNonLink is returned when ResolveLink is called on a node that is not a link
	ErrNonLink = errorType("non-link found at given path")
	// ErrNoSuchLink is returned when ResolveLink is called on a path that does not exist
	ErrNoSuchLink = errorType("no such link found")
	// ErrArrayOutOfRange is returned when Resolve link is called on a list that where the index is out of range
	ErrArrayOutOfRange = errorType("array index out of range")
	// ErrNoLinks is returned when we try to traverse through a terminal
	ErrNoLinks = errorType("tried to resolve through object that had no links")
)

Variables

This section is empty.

Functions

func ErrorAtPath

func ErrorAtPath(base ipld.Path, baseError error) error

func ErrorAtPathSegment

func ErrorAtPathSegment(seg ipld.PathSegment, base ipld.Path, baseError error) error

Types

type Decoder added in v0.2.0

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

func NewDecoder added in v0.2.0

func NewDecoder() *Decoder

func NewDecoderWithLS added in v0.2.1

func NewDecoderWithLS(ls ipld.LinkSystem) *Decoder

func (*Decoder) DecodeNode added in v0.2.0

func (d *Decoder) DecodeNode(ctx context.Context, b blocks.Block) (UniversalNode, error)

DecodeNode builds a UniversalNode from a block

func (*Decoder) RegisterCodec added in v0.2.0

func (d *Decoder) RegisterCodec(codec uint64, prototype ipld.NodePrototype, converter NodeConverter)

RegisterCodec registers a specialized prototype & converter for a specific codec

type LegacyNode

type LegacyNode struct {
	blocks.Block
	ipld.Node
}

LegacyNode wraps a go-ipld-prime node & a block so that it can be treated as a legacy ipld format node

func (*LegacyNode) Copy

func (ln *LegacyNode) Copy() format.Node

Copy returns a deep copy of this node

func (ln *LegacyNode) Links() []*format.Link

Links is a helper function that returns all links within this object

func (*LegacyNode) MarshalJSON added in v0.1.1

func (ln *LegacyNode) MarshalJSON() ([]byte, error)

MarshalJSON implements a JSON Marshaller interface for objects that expect marshalled json

func (*LegacyNode) Resolve

func (ln *LegacyNode) Resolve(path []string) (interface{}, []string, error)

Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse

func (ln *LegacyNode) ResolveLink(path []string) (*format.Link, []string, error)

ResolveLink is a helper function that calls resolve and asserts the output is a link

func (*LegacyNode) Size

func (ln *LegacyNode) Size() (uint64, error)

Size returns the size in bytes of the serialized object

func (*LegacyNode) Stat

func (ln *LegacyNode) Stat() (*format.NodeStat, error)

TODO: not sure if stat deserves to stay

func (*LegacyNode) Tree

func (ln *LegacyNode) Tree(path string, depth int) []string

Tree lists all paths within the object under 'path', and up to the given depth. To list the entire object (similar to `find .`) pass "" and -1

type NodeConverter

type NodeConverter func(b blocks.Block, nd ipld.Node) (UniversalNode, error)

NodeConverter converts a go-ipld-prime node + block combination to a UniversalNode that satisfies both current and legacy ipld formats

type UniversalNode

type UniversalNode interface {
	ipld.Node
	format.Node
}

UniversalNode satisfies both go-ipld-prime interfaces and legacy interfaces

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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