ipld

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0, MIT Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rebind

func Rebind[T any](nd datamodel.Node, typ schema.Type) (ptrVal T, err error)

Rebind takes a Node and binds it to the Go type according to the passed schema.

Types

type Block

type Block = block.Block

type Builder

type Builder interface {
	ToIPLD() (Node, error)
}

Builder can be modeled as an IPLD data and provides a `ToIPLD` method to build itself into a `datamodel.Node`.

type Link = ipld.Link

type Node

type Node = ipld.Node

func WrapWithRecovery

func WrapWithRecovery(ptrVal interface{}, typ schema.Type) (nd Node, err error)

WrapWithRecovery behaves like bindnode.Wrap but converts panics into errors

type View

type View interface {
	// Root is the root block of the IPLD DAG this is the view of. This is the
	// block from which all other blocks are linked directly or transitively.
	Root() Block
	// Blocks returns an iterator of all the IPLD blocks that are included in
	// this view.
	//
	// It is RECOMMENDED that implementations return blocks in bottom up order
	// (i.e. leaf blocks first, root block last).
	//
	// Iterator MUST include the root block otherwise it will lead encoders into
	// omitting it when encoding the view into a CAR archive.
	Blocks() iter.Seq2[Block, error]
}

View represents a materialized IPLD DAG View, which provides a generic traversal API. It is useful for encoding (potentially partial) IPLD DAGs into content archives (e.g. CARs).

type ViewBuilder

type ViewBuilder[V View] interface {
	// BuildIPLDView encodes all the blocks and creates a new IPLDView instance over them.
	BuildIPLDView() V
}

ViewBuilder represents a materializable IPLD DAG View. It is a useful abstraction that can be used to defer actual IPLD encoding.

Note that represented DAG could be partial implying that some of the blocks may not be included. This by design allowing a user to include whatever blocks they want to include.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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