dagpb

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: Apache-2.0, MIT Imports: 12 Imported by: 0

README

go-ipld-prime-proto

Coverage Status Travis CI

This Go module is deprecated. Use go-codec-dagpb instead.

An implementation of the DAG Protobuf for the go-ipld-prime library

Table of Contents

Background

The package adds Dag Protobuf support to go-ipld-prime. It is designed primarily as an adjunct to go-ipld-prime to enable using selectors and Graphsync, features which are unique to go-ipld-prime, with UnixFS v1 files encoded in protobuf.

go-ipld-prime-proto is primarily used to run selectors against Dag Protobuf encoded IPLD Graphs. It does not include robust facilities to support actual creation of DAG protobuf nodes, and none of the actual features for working with files contained in UnixFS. However, it can read, traverse and copy UnixFS data, which is what you need to run selectors and graphsync against existing UnixFS data.

Install

go-ipld-prime-proto requires Go >= 1.13 and can be installed using Go modules

Usage

To run a selector traversal against a graph encoded in Dag-Protobuf, you need to configure it with a custom NodeBuilderChooser. The simplest way to create such a node builder chooser is to take an existing function and pass it to AddDagPBSupportToChooser. This will add support for Dag Protobuf and Raw node encodings, the two types required by UnixFS.

Example:


var existing traversal.NodeBuilderChooser = func(ipld.Link, ipld.LinkContext) ipld.NodeBuilder {
	return ipldfree.NodeBuilder()
}
  
var pbChooser traversal.NodeBuilderChooser = 
dagpb.AddDagPBSupportToChooser(existing)

var selector selector.Selector
var loader ipld.Loader
var unixfsCid cid.Cid

// Load the first node
unixFSRootNode, err := cidlink.Link{Cid: unixfsCid}.Load(ipld.LinkContext{}, dagpb.PBNode__NodeBuilder(), loader)

// execute the traversal
err = traversal.Progress{
  Cfg: &traversal.Config{
    LinkLoader:             loader,
    LinkNodeBuilderChooser: pbChooser,
  },
}.WalkAdv(unixFSRootNode, allSelector, func(pg traversal.Progress, nd ipld.Node, r traversal.VisitReason) error {
  // do something with your traversed nodes here
}

All so checkout unixfs_test.go for good example of a complete setup with UnixFS files.

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

License

This library is dual-licensed under Apache 2.0 and MIT terms.

Copyright 2019. Protocol Labs, Inc.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoAutomaticDecoding means the NodeBuilder must provide a fast path decoding method on its own
	ErrNoAutomaticDecoding = errors.New("No automatic decoding for this type, node builder must provide fast path")
	// ErrNoAutomaticEncoding means the Node must provide a fast path encoding method on its own
	ErrNoAutomaticEncoding = errors.New("No automatic encoding for this type, node must provide fast path")
)
View Source
var Type typeSlab

Type is a struct embeding a NodePrototype/Type for every Node implementation in this package. One of its major uses is to start the construction of a value. You can use it like this:

dagpb.Type.YourTypeName.NewBuilder().BeginMap() //...

and:

dagpb.Type.OtherTypeName.NewBuilder().AssignString("x") // ...

Functions

func AddDagPBSupportToChooser

AddDagPBSupportToChooser takes an existing NodeBuilderChooser and subs in Protobuf and Raw node builders where neccesary

func PBDecoder

func PBDecoder(nb ipld.NodeAssembler, r io.Reader) error

PBDecoder is a decoder function for Dag Protobuf nodes

func PBEncoder

func PBEncoder(n ipld.Node, w io.Writer) error

PBEncoder is a encoder function that encodes to Dag Protobuf

func RawDecoder

func RawDecoder(nb ipld.NodeAssembler, r io.Reader) error

RawDecoder is a decoder function for raw coded nodes

func RawEncoder

func RawEncoder(n ipld.Node, w io.Writer) error

RawEncoder encodes a node to a raw block structure

Types

type Bytes

type Bytes = *_Bytes

Bytes matches the IPLD Schema type "Bytes". It has bytes kind.

func (Bytes) AsBool

func (Bytes) AsBool() (bool, error)

func (Bytes) AsBytes

func (n Bytes) AsBytes() ([]byte, error)

func (Bytes) AsFloat

func (Bytes) AsFloat() (float64, error)

func (Bytes) AsInt

func (Bytes) AsInt() (int64, error)
func (Bytes) AsLink() (ipld.Link, error)

func (Bytes) AsString

func (Bytes) AsString() (string, error)

func (Bytes) Bytes

func (n Bytes) Bytes() []byte

func (Bytes) IsAbsent

func (Bytes) IsAbsent() bool

func (Bytes) IsNull

func (Bytes) IsNull() bool

func (Bytes) Kind added in v0.1.1

func (Bytes) Kind() ipld.Kind

func (Bytes) Length

func (Bytes) Length() int64

func (Bytes) ListIterator

func (Bytes) ListIterator() ipld.ListIterator

func (Bytes) LookupByIndex

func (Bytes) LookupByIndex(idx int64) (ipld.Node, error)

func (Bytes) LookupByNode

func (Bytes) LookupByNode(ipld.Node) (ipld.Node, error)

func (Bytes) LookupBySegment

func (Bytes) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (Bytes) LookupByString

func (Bytes) LookupByString(string) (ipld.Node, error)

func (Bytes) MapIterator

func (Bytes) MapIterator() ipld.MapIterator

func (Bytes) Prototype

func (Bytes) Prototype() ipld.NodePrototype

func (Bytes) Representation

func (n Bytes) Representation() ipld.Node

func (Bytes) Type

func (Bytes) Type() schema.Type

type Int

type Int = *_Int

Int matches the IPLD Schema type "Int". It has int kind.

func (Int) AsBool

func (Int) AsBool() (bool, error)

func (Int) AsBytes

func (Int) AsBytes() ([]byte, error)

func (Int) AsFloat

func (Int) AsFloat() (float64, error)

func (Int) AsInt

func (n Int) AsInt() (int64, error)
func (Int) AsLink() (ipld.Link, error)

func (Int) AsString

func (Int) AsString() (string, error)

func (Int) Int

func (n Int) Int() int64

func (Int) IsAbsent

func (Int) IsAbsent() bool

func (Int) IsNull

func (Int) IsNull() bool

func (Int) Kind added in v0.1.1

func (Int) Kind() ipld.Kind

func (Int) Length

func (Int) Length() int64

func (Int) ListIterator

func (Int) ListIterator() ipld.ListIterator

func (Int) LookupByIndex

func (Int) LookupByIndex(idx int64) (ipld.Node, error)

func (Int) LookupByNode

func (Int) LookupByNode(ipld.Node) (ipld.Node, error)

func (Int) LookupBySegment

func (Int) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (Int) LookupByString

func (Int) LookupByString(string) (ipld.Node, error)

func (Int) MapIterator

func (Int) MapIterator() ipld.MapIterator

func (Int) Prototype

func (Int) Prototype() ipld.NodePrototype

func (Int) Representation

func (n Int) Representation() ipld.Node

func (Int) Type

func (Int) Type() schema.Type
type Link = *_Link

Link matches the IPLD Schema type "Link". It has link kind.

func (Link) AsBool

func (Link) AsBool() (bool, error)

func (Link) AsBytes

func (Link) AsBytes() ([]byte, error)

func (Link) AsFloat

func (Link) AsFloat() (float64, error)

func (Link) AsInt

func (Link) AsInt() (int64, error)
func (n Link) AsLink() (ipld.Link, error)

func (Link) AsString

func (Link) AsString() (string, error)

func (Link) IsAbsent

func (Link) IsAbsent() bool

func (Link) IsNull

func (Link) IsNull() bool

func (Link) Kind added in v0.1.1

func (Link) Kind() ipld.Kind

func (Link) Length

func (Link) Length() int64
func (n Link) Link() ipld.Link

func (Link) ListIterator

func (Link) ListIterator() ipld.ListIterator

func (Link) LookupByIndex

func (Link) LookupByIndex(idx int64) (ipld.Node, error)

func (Link) LookupByNode

func (Link) LookupByNode(ipld.Node) (ipld.Node, error)

func (Link) LookupBySegment

func (Link) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (Link) LookupByString

func (Link) LookupByString(string) (ipld.Node, error)

func (Link) MapIterator

func (Link) MapIterator() ipld.MapIterator

func (Link) Prototype

func (Link) Prototype() ipld.NodePrototype

func (Link) Representation

func (n Link) Representation() ipld.Node

func (Link) Type

func (Link) Type() schema.Type

type MaybeBytes

type MaybeBytes = *_Bytes__Maybe

func (MaybeBytes) AsNode

func (m MaybeBytes) AsNode() ipld.Node

func (MaybeBytes) Exists

func (m MaybeBytes) Exists() bool

func (MaybeBytes) IsAbsent

func (m MaybeBytes) IsAbsent() bool

func (MaybeBytes) IsNull

func (m MaybeBytes) IsNull() bool

func (MaybeBytes) Must

func (m MaybeBytes) Must() Bytes

type MaybeInt

type MaybeInt = *_Int__Maybe

func (MaybeInt) AsNode

func (m MaybeInt) AsNode() ipld.Node

func (MaybeInt) Exists

func (m MaybeInt) Exists() bool

func (MaybeInt) IsAbsent

func (m MaybeInt) IsAbsent() bool

func (MaybeInt) IsNull

func (m MaybeInt) IsNull() bool

func (MaybeInt) Must

func (m MaybeInt) Must() Int
type MaybeLink = *_Link__Maybe

func (MaybeLink) AsNode

func (m MaybeLink) AsNode() ipld.Node

func (MaybeLink) Exists

func (m MaybeLink) Exists() bool

func (MaybeLink) IsAbsent

func (m MaybeLink) IsAbsent() bool

func (MaybeLink) IsNull

func (m MaybeLink) IsNull() bool

func (MaybeLink) Must

func (m MaybeLink) Must() Link
type MaybePBLink = *_PBLink__Maybe

func (MaybePBLink) AsNode

func (m MaybePBLink) AsNode() ipld.Node

func (MaybePBLink) Exists

func (m MaybePBLink) Exists() bool

func (MaybePBLink) IsAbsent

func (m MaybePBLink) IsAbsent() bool

func (MaybePBLink) IsNull

func (m MaybePBLink) IsNull() bool

func (MaybePBLink) Must

func (m MaybePBLink) Must() PBLink
type MaybePBLinks = *_PBLinks__Maybe

func (MaybePBLinks) AsNode

func (m MaybePBLinks) AsNode() ipld.Node

func (MaybePBLinks) Exists

func (m MaybePBLinks) Exists() bool

func (MaybePBLinks) IsAbsent

func (m MaybePBLinks) IsAbsent() bool

func (MaybePBLinks) IsNull

func (m MaybePBLinks) IsNull() bool

func (MaybePBLinks) Must

func (m MaybePBLinks) Must() PBLinks

type MaybePBNode

type MaybePBNode = *_PBNode__Maybe

func (MaybePBNode) AsNode

func (m MaybePBNode) AsNode() ipld.Node

func (MaybePBNode) Exists

func (m MaybePBNode) Exists() bool

func (MaybePBNode) IsAbsent

func (m MaybePBNode) IsAbsent() bool

func (MaybePBNode) IsNull

func (m MaybePBNode) IsNull() bool

func (MaybePBNode) Must

func (m MaybePBNode) Must() PBNode

type MaybeRawNode

type MaybeRawNode = *_RawNode__Maybe

func (MaybeRawNode) AsNode

func (m MaybeRawNode) AsNode() ipld.Node

func (MaybeRawNode) Exists

func (m MaybeRawNode) Exists() bool

func (MaybeRawNode) IsAbsent

func (m MaybeRawNode) IsAbsent() bool

func (MaybeRawNode) IsNull

func (m MaybeRawNode) IsNull() bool

func (MaybeRawNode) Must

func (m MaybeRawNode) Must() RawNode

type MaybeString

type MaybeString = *_String__Maybe

func (MaybeString) AsNode

func (m MaybeString) AsNode() ipld.Node

func (MaybeString) Exists

func (m MaybeString) Exists() bool

func (MaybeString) IsAbsent

func (m MaybeString) IsAbsent() bool

func (MaybeString) IsNull

func (m MaybeString) IsNull() bool

func (MaybeString) Must

func (m MaybeString) Must() String
type PBLink = *_PBLink

PBLink matches the IPLD Schema type "PBLink". It has Struct type-kind, and may be interrogated like map kind.

func (PBLink) AsBool

func (PBLink) AsBool() (bool, error)

func (PBLink) AsBytes

func (PBLink) AsBytes() ([]byte, error)

func (PBLink) AsFloat

func (PBLink) AsFloat() (float64, error)

func (PBLink) AsInt

func (PBLink) AsInt() (int64, error)
func (PBLink) AsLink() (ipld.Link, error)

func (PBLink) AsString

func (PBLink) AsString() (string, error)

func (PBLink) IsAbsent

func (PBLink) IsAbsent() bool

func (PBLink) IsNull

func (PBLink) IsNull() bool

func (PBLink) Kind added in v0.1.1

func (PBLink) Kind() ipld.Kind

func (PBLink) Length

func (PBLink) Length() int64

func (PBLink) ListIterator

func (PBLink) ListIterator() ipld.ListIterator

func (PBLink) LookupByIndex

func (PBLink) LookupByIndex(idx int64) (ipld.Node, error)

func (PBLink) LookupByNode

func (n PBLink) LookupByNode(key ipld.Node) (ipld.Node, error)

func (PBLink) LookupBySegment

func (n PBLink) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (PBLink) LookupByString

func (n PBLink) LookupByString(key string) (ipld.Node, error)

func (PBLink) MapIterator

func (n PBLink) MapIterator() ipld.MapIterator

func (PBLink) Prototype

func (PBLink) Prototype() ipld.NodePrototype

func (PBLink) Representation

func (n PBLink) Representation() ipld.Node

func (PBLink) Type

func (PBLink) Type() schema.Type
type PBLinks = *_PBLinks

PBLinks matches the IPLD Schema type "PBLinks". It has list kind.

func (PBLinks) AsBool

func (PBLinks) AsBool() (bool, error)

func (PBLinks) AsBytes

func (PBLinks) AsBytes() ([]byte, error)

func (PBLinks) AsFloat

func (PBLinks) AsFloat() (float64, error)

func (PBLinks) AsInt

func (PBLinks) AsInt() (int64, error)
func (PBLinks) AsLink() (ipld.Link, error)

func (PBLinks) AsString

func (PBLinks) AsString() (string, error)

func (PBLinks) IsAbsent

func (PBLinks) IsAbsent() bool

func (PBLinks) IsNull

func (PBLinks) IsNull() bool

func (PBLinks) Iterator added in v0.1.1

func (n PBLinks) Iterator() *PBLinks__Itr

func (PBLinks) Kind added in v0.1.1

func (PBLinks) Kind() ipld.Kind

func (PBLinks) Length

func (n PBLinks) Length() int64

func (PBLinks) ListIterator

func (n PBLinks) ListIterator() ipld.ListIterator

func (PBLinks) LookupByIndex

func (n PBLinks) LookupByIndex(idx int64) (ipld.Node, error)

func (PBLinks) LookupByNode

func (n PBLinks) LookupByNode(k ipld.Node) (ipld.Node, error)

func (PBLinks) LookupBySegment

func (n PBLinks) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (PBLinks) LookupByString

func (PBLinks) LookupByString(string) (ipld.Node, error)

func (PBLinks) MapIterator

func (PBLinks) MapIterator() ipld.MapIterator

func (PBLinks) Prototype

func (PBLinks) Prototype() ipld.NodePrototype

func (PBLinks) Representation

func (n PBLinks) Representation() ipld.Node

func (PBLinks) Type

func (PBLinks) Type() schema.Type
type PBLinks__Itr struct {
	// contains filtered or unexported fields
}
func (itr *PBLinks__Itr) Done() bool
func (itr *PBLinks__Itr) Next() (idx int64, v PBLink)

type PBNode

type PBNode = *_PBNode

PBNode matches the IPLD Schema type "PBNode". It has Struct type-kind, and may be interrogated like map kind.

func (PBNode) AsBool

func (PBNode) AsBool() (bool, error)

func (PBNode) AsBytes

func (PBNode) AsBytes() ([]byte, error)

func (PBNode) AsFloat

func (PBNode) AsFloat() (float64, error)

func (PBNode) AsInt

func (PBNode) AsInt() (int64, error)
func (PBNode) AsLink() (ipld.Link, error)

func (PBNode) AsString

func (PBNode) AsString() (string, error)

func (PBNode) EncodeDagProto

func (nd PBNode) EncodeDagProto(w io.Writer) error

EncodeDagProto is a fast path encoding to protobuf for PBNode types

func (PBNode) IsAbsent

func (PBNode) IsAbsent() bool

func (PBNode) IsNull

func (PBNode) IsNull() bool

func (PBNode) Kind added in v0.1.1

func (PBNode) Kind() ipld.Kind

func (PBNode) Length

func (PBNode) Length() int64

func (PBNode) ListIterator

func (PBNode) ListIterator() ipld.ListIterator

func (PBNode) LookupByIndex

func (PBNode) LookupByIndex(idx int64) (ipld.Node, error)

func (PBNode) LookupByNode

func (n PBNode) LookupByNode(key ipld.Node) (ipld.Node, error)

func (PBNode) LookupBySegment

func (n PBNode) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (PBNode) LookupByString

func (n PBNode) LookupByString(key string) (ipld.Node, error)

func (PBNode) MapIterator

func (n PBNode) MapIterator() ipld.MapIterator

func (PBNode) Prototype

func (PBNode) Prototype() ipld.NodePrototype

func (PBNode) Representation

func (n PBNode) Representation() ipld.Node

func (PBNode) Type

func (PBNode) Type() schema.Type

type RawNode

type RawNode = *_RawNode

RawNode matches the IPLD Schema type "RawNode". It has bytes kind.

func (RawNode) AsBool

func (RawNode) AsBool() (bool, error)

func (RawNode) AsBytes

func (n RawNode) AsBytes() ([]byte, error)

func (RawNode) AsFloat

func (RawNode) AsFloat() (float64, error)

func (RawNode) AsInt

func (RawNode) AsInt() (int64, error)
func (RawNode) AsLink() (ipld.Link, error)

func (RawNode) AsString

func (RawNode) AsString() (string, error)

func (RawNode) Bytes

func (n RawNode) Bytes() []byte

func (RawNode) EncodeDagRaw

func (nd RawNode) EncodeDagRaw(w io.Writer) error

EncodeDagRaw is a fast path encoding to protobuf for RawNode types

func (RawNode) IsAbsent

func (RawNode) IsAbsent() bool

func (RawNode) IsNull

func (RawNode) IsNull() bool

func (RawNode) Kind added in v0.1.1

func (RawNode) Kind() ipld.Kind

func (RawNode) Length

func (RawNode) Length() int64

func (RawNode) ListIterator

func (RawNode) ListIterator() ipld.ListIterator

func (RawNode) LookupByIndex

func (RawNode) LookupByIndex(idx int64) (ipld.Node, error)

func (RawNode) LookupByNode

func (RawNode) LookupByNode(ipld.Node) (ipld.Node, error)

func (RawNode) LookupBySegment

func (RawNode) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (RawNode) LookupByString

func (RawNode) LookupByString(string) (ipld.Node, error)

func (RawNode) MapIterator

func (RawNode) MapIterator() ipld.MapIterator

func (RawNode) Prototype

func (RawNode) Prototype() ipld.NodePrototype

func (RawNode) Representation

func (n RawNode) Representation() ipld.Node

func (RawNode) Type

func (RawNode) Type() schema.Type

type String

type String = *_String

String matches the IPLD Schema type "String". It has string kind.

func (String) AsBool

func (String) AsBool() (bool, error)

func (String) AsBytes

func (String) AsBytes() ([]byte, error)

func (String) AsFloat

func (String) AsFloat() (float64, error)

func (String) AsInt

func (String) AsInt() (int64, error)
func (String) AsLink() (ipld.Link, error)

func (String) AsString

func (n String) AsString() (string, error)

func (String) IsAbsent

func (String) IsAbsent() bool

func (String) IsNull

func (String) IsNull() bool

func (String) Kind added in v0.1.1

func (String) Kind() ipld.Kind

func (String) Length

func (String) Length() int64

func (String) ListIterator

func (String) ListIterator() ipld.ListIterator

func (String) LookupByIndex

func (String) LookupByIndex(idx int64) (ipld.Node, error)

func (String) LookupByNode

func (String) LookupByNode(ipld.Node) (ipld.Node, error)

func (String) LookupBySegment

func (String) LookupBySegment(seg ipld.PathSegment) (ipld.Node, error)

func (String) LookupByString

func (String) LookupByString(string) (ipld.Node, error)

func (String) MapIterator

func (String) MapIterator() ipld.MapIterator

func (String) Prototype

func (String) Prototype() ipld.NodePrototype

func (String) Representation

func (n String) Representation() ipld.Node

func (String) String

func (n String) String() string

func (String) Type

func (String) Type() schema.Type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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