codec

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 5 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(n ipld.Node, sink shared.TokenSink) error

Marshal provides a very general node-to-tokens marshalling feature. It can handle either cbor or json by being combined with a refmt TokenSink.

It is valid for all the data model types except links, which are only supported if the nodes are typed and provide additional information to clarify how links should be encoded through their type info. (The dag-cbor and dag-json formats can be used if links are of CID implementation and need to be encoded in a schemafree way.)

func Unmarshal

func Unmarshal(na ipld.NodeAssembler, tokSrc shared.TokenSource) error

Unmarshal provides a very general tokens-to-node unmarshalling feature. It can handle either cbor or json by being combined with a refmt TokenSink.

The unmarshalled data is fed to the given NodeAssembler, which accumulates it; at the end, any error is returned from the Unmarshal method, and the user can pick up the finished Node from wherever their assembler has it. Typical usage might look like the following:

nb := basicnode.Style__Any{}.NewBuilder()
err := codec.Unmarshal(nb, json.Decoder(reader))
n := nb.Build()

It is valid for all the data model types except links, which are only supported if the nodes are typed and provide additional information to clarify how links should be decoded through their type info. (The dag-cbor and dag-json formats can be used if links are of CID implementation and need to be decoded in a schemafree way.)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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