Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeBlock(block blocks.Block) (node.Node, error)
- func DecodeInto(b []byte, v interface{}) error
- func DumpObject(obj interface{}) ([]byte, error)
- func EncoderFilter(i interface{}) interface{}
- type IpldLinkDecoder
- type Node
- func (n *Node) Cid() *cid.Cid
- func (n *Node) Copy() node.Node
- func (n *Node) Links() []*node.Link
- func (n *Node) Loggable() map[string]interface{}
- func (n *Node) MarshalJSON() ([]byte, error)
- func (n *Node) RawData() []byte
- func (n *Node) Resolve(path []string) (interface{}, []string, error)
- func (n *Node) ResolveLink(path []string) (*node.Link, []string, error)
- func (n *Node) Size() (uint64, error)
- func (n *Node) Stat() (*node.NodeStat, error)
- func (n *Node) String() string
- func (n *Node) Tree(path string, depth int) []string
Constants ¶
const CBORTagLink = 42
Variables ¶
var ErrNoSuchLink = errors.New("no such link found")
Functions ¶
func DecodeBlock ¶ added in v1.2.3
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 ¶
DecodeInto decodes a serialized ipld cbor object into the given object.
func DumpObject ¶ added in v0.5.0
func EncoderFilter ¶ added in v0.5.0
func EncoderFilter(i interface{}) interface{}
Types ¶
type IpldLinkDecoder ¶ added in v0.5.0
type IpldLinkDecoder struct{}
func (*IpldLinkDecoder) DecodeTarget ¶ added in v0.5.0
func (d *IpldLinkDecoder) DecodeTarget() interface{}
func (*IpldLinkDecoder) GetTag ¶ added in v0.5.0
func (d *IpldLinkDecoder) GetTag() uint64
func (*IpldLinkDecoder) PostDecode ¶ added in v0.5.0
func (d *IpldLinkDecoder) PostDecode(i interface{}) (interface{}, error)
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func Decode ¶
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.