dagjson

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Several groups of exported symbols are available at different levels of abstraction:

  • You might just want the multicodec registration! Then never deal with this package directly again.
  • You might want to use the `Encode(Node,Writer)` and `Decode(NodeAssembler,Reader)` functions directly.
  • You might want to use `ReusableEncoder` and `ReusableDecoder` types and their configuration options, then use their Encode and Decode methods with that additional control.
  • You might want to use the lower-level TokenReader and TokenWriter tools to process the serial data as a stream, without necessary creating ld Nodes at all.
  • (this is a stretch) You might want to use some of the individual token processing functions, perhaps as part of a totally new codec that just happens to share some behaviors with this one.

The first three are exported from this package. The last two can be found in the "./token" subpackage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unmarshal

func Unmarshal(into ld.NodeAssembler, input io.Reader) error

Unmarshal reads data from input, parses it as DAG-JSON, and unfolds the data into the given NodeAssembler.

The strict interpretation of DAG-JSON is used. Use a ReusableMarshaller and set its DecoderConfig if you need looser or otherwise customized decoding rules.

This function is the same as the function found for DAG-JSON in the default multicodec registry.

Types

type ReusableUnmarshaller

type ReusableUnmarshaller struct {
	InitialBudget int64
	// contains filtered or unexported fields
}

ReusableUnmarshaller has an Unmarshal method, and also supports customizable DecoderConfig and resource budgets.

The Unmarshal method may be used repeatedly (although not concurrently). Keeping a ReusableUnmarshaller around and using it repeatedly may allow the user to amortize some allocations (some internal buffers can be reused).

func (*ReusableUnmarshaller) SetDecoderConfig

func (r *ReusableUnmarshaller) SetDecoderConfig(cfg jsontoken.DecoderConfig)

func (*ReusableUnmarshaller) SetInitialBudget

func (r *ReusableUnmarshaller) SetInitialBudget(budget int64)

func (*ReusableUnmarshaller) Unmarshal

func (r *ReusableUnmarshaller) Unmarshal(into ld.NodeAssembler, input io.Reader) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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