graphson

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: Apache-2.0 Imports: 12 Imported by: 6

Documentation

Index

Constants

View Source
const (
	TypeKey  = "@type"
	ValueKey = "@value"
)

graphson encoding type / value keys

Variables

This section is empty.

Functions

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal returns the graphson encoding of v.

func MarshalToString

func MarshalToString(v interface{}) (string, error)

MarshalToString returns the graphson encoding of v as string.

func RegisterTypeDecoder

func RegisterTypeDecoder(typ string, dec jsoniter.ValDecoder)

RegisterTypeDecoder register type decoder for typ.

func RegisterTypeEncoder

func RegisterTypeEncoder(typ string, enc jsoniter.ValEncoder)

RegisterTypeEncoder register type encoder for typ.

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal parses the graphson encoded data and stores the result in the value pointed to by v.

func UnmarshalFromString

func UnmarshalFromString(str string, v interface{}) error

UnmarshalFromString parses the graphson encoded str and stores the result in the value pointed to by v.

Types

type Decoder

type Decoder interface {
	Decode(interface{}) error
}

Decoder defines a graphson decoder.

func NewDecoder

func NewDecoder(r io.Reader) Decoder

NewDecoder create a graphson decoder.

type Encoder

type Encoder interface {
	Encode(interface{}) error
}

Encoder defines a graphson encoder.

func NewEncoder

func NewEncoder(w io.Writer) Encoder

NewEncoder create a graphson encoder.

type Marshaler

type Marshaler interface {
	MarshalGraphson() ([]byte, error)
}

Marshaler is the interface implemented by types that can marshal themselves as graphson.

type RawMessage

type RawMessage []byte

RawMessage is a raw encoded graphson value.

func (RawMessage) MarshalGraphson

func (m RawMessage) MarshalGraphson() ([]byte, error)

MarshalGraphson returns m as the graphson encoding of m.

func (*RawMessage) UnmarshalGraphson

func (m *RawMessage) UnmarshalGraphson(data []byte) error

UnmarshalGraphson sets *m to a copy of data.

type Type

type Type string

A Type is a graphson type.

const (
	Timestamp Type = "g:Timestamp"
	Date      Type = "g:Date"
)

graphson typed value types.

func (Type) CheckType

func (typ Type) CheckType(other Type) error

CheckType implements typeChecker interface.

func (Type) String

func (typ Type) String() string

String implements fmt.Stringer interface.

type Typer

type Typer interface {
	GraphsonType() Type
}

Typer is the interface implemented by types that define an underlying graphson type.

type Types

type Types []Type

Types is a slice of Type.

func (Types) CheckType

func (types Types) CheckType(typ Type) error

CheckType implements typeChecker interface.

func (Types) Contains

func (types Types) Contains(typ Type) bool

Contains reports whether a slice of types contains a particular type.

func (Types) String

func (types Types) String() string

String implements fmt.Stringer interface.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalGraphson([]byte) error
}

Unmarshaler is the interface implemented by types that can unmarshal a graphson description of themselves.

Jump to

Keyboard shortcuts

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