cidlink

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, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMulticodecDecoder

func RegisterMulticodecDecoder(hook uint64, fn MulticodecDecoder)

RegisterMulticodecDecoder is used to register multicodec features. It adjusts a global registry and may only be used at program init time; it is meant to provide a plugin system, not a configuration mechanism.

func RegisterMulticodecEncoder

func RegisterMulticodecEncoder(hook uint64, fn MulticodecEncoder)

RegisterMulticodecEncoder is used to register multicodec features. It adjusts a global registry and may only be used at program init time; it is meant to provide a plugin system, not a configuration mechanism.

Types

type Link struct {
	cid.Cid
}

func (Link) LinkBuilder

func (lnk Link) LinkBuilder() ipld.LinkBuilder

func (Link) Load

func (lnk Link) Load(ctx context.Context, lnkCtx ipld.LinkContext, na ipld.NodeAssembler, loader ipld.Loader) error

func (Link) String

func (lnk Link) String() string

type LinkBuilder

type LinkBuilder struct {
	cid.Prefix
}

func (LinkBuilder) Build

func (lb LinkBuilder) Build(ctx context.Context, lnkCtx ipld.LinkContext, node ipld.Node, storer ipld.Storer) (ipld.Link, error)

type MulticodecDecodeTable

type MulticodecDecodeTable map[uint64]MulticodecDecoder

type MulticodecDecoder

type MulticodecDecoder func(ipld.NodeAssembler, io.Reader) error

MulticodecDecoder builds an ipld.Node by unmarshalling bytes and funnelling the data tree into an ipld.NodeAssembler. The resulting Node is not returned; typically you call this function with an ipld.NodeBuilder, and you can extract the result from there.

MulticodecDecoder are used by registering them in a MulticodecDecoderTable, which makes them available to be used internally by cidlink.Link.Load.

Consider implementing decoders to probe their NodeBuilder to see if it has special features that may be able to do the job more efficiently. For example, ipldcbor.NodeBuilder has special unmarshaller functions that know how to fastpath their work *if* we're doing a cbor decode; if possible, detect and use that; if not, fall back to general generic NodeBuilder usage.

type MulticodecEncodeTable

type MulticodecEncodeTable map[uint64]MulticodecEncoder

type MulticodecEncoder

type MulticodecEncoder func(ipld.Node, io.Writer) error

MulticodecEncoder marshals and ipld.Node into bytes and sends them to an io.Writer.

MulticodecEncoder are used by registering them in a MulticodecEncoderTable, which makes them available to be used internally by cidlink.LinkBuilder.

Tends to be implemented by probing the node to see if it matches a special interface that we know can do this particular kind of encoding (e.g. if you're using ipldgit.Node and making a MulticodecEncoder to register as the rawgit multicodec, you'll probe for that specific thing, since it's implemented on the node itself), but may also be able to work based on the ipld.Node interface alone (e.g. you can do dag-cbor to any kind of Node).

Jump to

Keyboard shortcuts

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