cbornode

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 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const CBORTagLink = 42

Variables

View Source
var ErrNoSuchLink = errors.New("no such link found")

Functions

func DecodeBlock

func DecodeBlock(block blocks.Block) (node.Node, error)

Decode a CBOR encoded Block into an IPLD Node.

This method *does not* canonicalize and *will* preserve the CID. As a matter of fact, it will assume that `block.Cid()` returns the correct CID and will make no effort to validate this assumption.

In general, you should not be calling this method directly. Instead, you should be calling the `Decode` method from the `go-ipld-format` package. That method will pick the right decoder based on the Block's CID.

Note: This function keeps a reference to `block` and assumes that it is immutable.

func DecodeInto

func DecodeInto(b []byte, v interface{}) error

DecodeInto decodes a serialized ipld cbor object into the given object.

func DumpObject

func DumpObject(obj interface{}) ([]byte, error)

func EncoderFilter

func EncoderFilter(i interface{}) interface{}

Types

type IpldLinkDecoder

type IpldLinkDecoder struct{}

func (*IpldLinkDecoder) DecodeTarget

func (d *IpldLinkDecoder) DecodeTarget() interface{}

func (*IpldLinkDecoder) GetTag

func (d *IpldLinkDecoder) GetTag() uint64

func (*IpldLinkDecoder) PostDecode

func (d *IpldLinkDecoder) PostDecode(i interface{}) (interface{}, error)

type Node

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

func Decode

func Decode(b []byte, mhType uint64, mhLen int) (*Node, error)

Decode a CBOR object into an IPLD Node.

If passed a non-canonical CBOR node, this function will canonicalize it. Therefore, `bytes.Equal(b, Decode(b).RawData())` may not hold. If you already have a CID for this data and want to ensure that it doesn't change, you should use `DecodeBlock`. mhType is multihash code to use for hashing, for example mh.SHA2_256

Note: This function does not hold onto `b`. You may reuse it.

func FromJson

func FromJson(r io.Reader, mhType uint64, mhLen int) (*Node, error)

func WrapObject

func WrapObject(m interface{}, mhType uint64, mhLen int) (*Node, error)

func (*Node) Cid

func (n *Node) Cid() *cid.Cid

func (*Node) Copy

func (n *Node) Copy() node.Node
func (n *Node) Links() []*node.Link

func (*Node) Loggable

func (n *Node) Loggable() map[string]interface{}

func (*Node) MarshalJSON

func (n *Node) MarshalJSON() ([]byte, error)

func (*Node) RawData

func (n *Node) RawData() []byte

func (*Node) Resolve

func (n *Node) Resolve(path []string) (interface{}, []string, error)
func (n *Node) ResolveLink(path []string) (*node.Link, []string, error)

func (*Node) Size

func (n *Node) Size() (uint64, error)

func (*Node) Stat

func (n *Node) Stat() (*node.NodeStat, error)

func (*Node) String

func (n *Node) String() string

func (*Node) Tree

func (n *Node) Tree(path string, depth int) []string

Jump to

Keyboard shortcuts

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