codec

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalJSONIndent

func MarshalJSONIndent(cdc *LegacyAmino, obj interface{}) ([]byte, error)

MarshalJSONIndent provides a utility for indented JSON encoding of an object via an Amino codec. It returns an error if it cannot serialize or indent as JSON.

func MustMarshalJSONIndent

func MustMarshalJSONIndent(cdc *LegacyAmino, obj interface{}) []byte

MustMarshalJSONIndent executes MarshalJSONIndent except it panics upon failure.

func ProtoMarshalJSON

func ProtoMarshalJSON(msg proto.Message) ([]byte, error)

ProtoMarshalJSON provides an auxiliary function to return Proto3 JSON encoded bytes of a message.

func RegisterEvidences

func RegisterEvidences(cdc *LegacyAmino)

RegisterEvidences registers Tendermint evidence types with the provided Amino codec.

Types

type AminoCodec

type AminoCodec struct {
	*LegacyAmino
}

AminoCodec defines a codec that utilizes Codec for both binary and JSON encoding.

func NewAminoCodec

func NewAminoCodec(codec *LegacyAmino) *AminoCodec

NewAminoCodec returns a reference to a new AminoCodec

func (*AminoCodec) MarshalBinaryBare

func (ac *AminoCodec) MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)

MarshalBinaryBare implements BinaryMarshaler.MarshalBinaryBare method.

func (*AminoCodec) MarshalBinaryLengthPrefixed

func (ac *AminoCodec) MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)

MarshalBinaryLengthPrefixed implements BinaryMarshaler.MarshalBinaryLengthPrefixed method.

func (*AminoCodec) MarshalJSON

func (ac *AminoCodec) MarshalJSON(o proto.Message) ([]byte, error)

MarshalJSON implements JSONMarshaler.MarshalJSON method, it marshals to JSON using legacy amino codec.

func (*AminoCodec) MustMarshalBinaryBare

func (ac *AminoCodec) MustMarshalBinaryBare(o ProtoMarshaler) []byte

MustMarshalBinaryBare implements BinaryMarshaler.MustMarshalBinaryBare method.

func (*AminoCodec) MustMarshalBinaryLengthPrefixed

func (ac *AminoCodec) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte

MustMarshalBinaryLengthPrefixed implements BinaryMarshaler.MustMarshalBinaryLengthPrefixed method.

func (*AminoCodec) MustMarshalJSON

func (ac *AminoCodec) MustMarshalJSON(o proto.Message) []byte

MustMarshalJSON implements JSONMarshaler.MustMarshalJSON method, it executes MarshalJSON except it panics upon failure.

func (*AminoCodec) MustUnmarshalBinaryBare

func (ac *AminoCodec) MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler)

MustUnmarshalBinaryBare implements BinaryMarshaler.MustUnmarshalBinaryBare method.

func (*AminoCodec) MustUnmarshalBinaryLengthPrefixed

func (ac *AminoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)

MustUnmarshalBinaryLengthPrefixed implements BinaryMarshaler.MustUnmarshalBinaryLengthPrefixed method.

func (*AminoCodec) MustUnmarshalJSON

func (ac *AminoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)

MustUnmarshalJSON implements JSONMarshaler.MustUnmarshalJSON method, it executes UnmarshalJSON except it panics upon failure.

func (*AminoCodec) UnmarshalBinaryBare

func (ac *AminoCodec) UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error

UnmarshalBinaryBare implements BinaryMarshaler.UnmarshalBinaryBare method.

func (*AminoCodec) UnmarshalBinaryLengthPrefixed

func (ac *AminoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error

UnmarshalBinaryLengthPrefixed implements BinaryMarshaler.UnmarshalBinaryLengthPrefixed method.

func (*AminoCodec) UnmarshalJSON

func (ac *AminoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error

UnmarshalJSON implements JSONMarshaler.UnmarshalJSON method, it unmarshals from JSON using legacy amino codec.

type AminoMarshaler

type AminoMarshaler interface {
	MarshalAmino() ([]byte, error)
	UnmarshalAmino([]byte) error
	MarshalAminoJSON() ([]byte, error)
	UnmarshalAminoJSON([]byte) error
}

type BinaryMarshaler

type BinaryMarshaler interface {
	MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)
	MustMarshalBinaryBare(o ProtoMarshaler) []byte

	MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)
	MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte

	UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error
	MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler)

	UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error
	MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)

	types.AnyUnpacker
}

type JSONMarshaler

type JSONMarshaler interface {
	MarshalJSON(o proto.Message) ([]byte, error)
	MustMarshalJSON(o proto.Message) []byte

	UnmarshalJSON(bz []byte, ptr proto.Message) error
	MustUnmarshalJSON(bz []byte, ptr proto.Message)
}

type LegacyAmino

type LegacyAmino struct {
	Amino *amino.Codec
}

deprecated: LegacyAmino defines a wrapper for an Amino codec that properly handles protobuf types with Any's

func NewLegacyAmino

func NewLegacyAmino() *LegacyAmino

func (*LegacyAmino) MarshalBinaryBare

func (cdc *LegacyAmino) MarshalBinaryBare(o interface{}) ([]byte, error)

func (*LegacyAmino) MarshalBinaryLengthPrefixed

func (cdc *LegacyAmino) MarshalBinaryLengthPrefixed(o interface{}) ([]byte, error)

func (*LegacyAmino) MarshalJSON

func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error)

func (*LegacyAmino) MarshalJSONIndent

func (cdc *LegacyAmino) MarshalJSONIndent(o interface{}, prefix, indent string) ([]byte, error)

func (*LegacyAmino) MustMarshalBinaryBare

func (cdc *LegacyAmino) MustMarshalBinaryBare(o interface{}) []byte

func (*LegacyAmino) MustMarshalBinaryLengthPrefixed

func (cdc *LegacyAmino) MustMarshalBinaryLengthPrefixed(o interface{}) []byte

func (*LegacyAmino) MustMarshalJSON

func (cdc *LegacyAmino) MustMarshalJSON(o interface{}) []byte

func (*LegacyAmino) MustUnmarshalBinaryBare

func (cdc *LegacyAmino) MustUnmarshalBinaryBare(bz []byte, ptr interface{})

func (*LegacyAmino) MustUnmarshalBinaryLengthPrefixed

func (cdc *LegacyAmino) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{})

func (*LegacyAmino) MustUnmarshalJSON

func (cdc *LegacyAmino) MustUnmarshalJSON(bz []byte, ptr interface{})

func (*LegacyAmino) PrintTypes

func (cdc *LegacyAmino) PrintTypes(out io.Writer) error

func (*LegacyAmino) RegisterConcrete

func (cdc *LegacyAmino) RegisterConcrete(o interface{}, name string, copts *amino.ConcreteOptions)

func (*LegacyAmino) RegisterInterface

func (cdc *LegacyAmino) RegisterInterface(ptr interface{}, iopts *amino.InterfaceOptions)

func (*LegacyAmino) Seal

func (cdc *LegacyAmino) Seal()

func (*LegacyAmino) UnmarshalBinaryBare

func (cdc *LegacyAmino) UnmarshalBinaryBare(bz []byte, ptr interface{}) error

func (*LegacyAmino) UnmarshalBinaryLengthPrefixed

func (cdc *LegacyAmino) UnmarshalBinaryLengthPrefixed(bz []byte, ptr interface{}) error

func (*LegacyAmino) UnmarshalJSON

func (cdc *LegacyAmino) UnmarshalJSON(bz []byte, ptr interface{}) error

func (*LegacyAmino) UnpackAny

func (*LegacyAmino) UnpackAny(*types.Any, interface{}) error

type Marshaler

type Marshaler interface {
	BinaryMarshaler
	JSONMarshaler
}

type ProtoCodec

type ProtoCodec struct {
	// contains filtered or unexported fields
}

ProtoCodec defines a codec that utilizes Protobuf for both binary and JSON encoding.

func NewProtoCodec

func NewProtoCodec(anyUnpacker types.AnyUnpacker) *ProtoCodec

NewProtoCodec returns a reference to a new ProtoCodec

func (*ProtoCodec) MarshalBinaryBare

func (pc *ProtoCodec) MarshalBinaryBare(o ProtoMarshaler) ([]byte, error)

MarshalBinaryBare implements BinaryMarshaler.MarshalBinaryBare method.

func (*ProtoCodec) MarshalBinaryLengthPrefixed

func (pc *ProtoCodec) MarshalBinaryLengthPrefixed(o ProtoMarshaler) ([]byte, error)

MarshalBinaryLengthPrefixed implements BinaryMarshaler.MarshalBinaryLengthPrefixed method.

func (*ProtoCodec) MarshalJSON

func (pc *ProtoCodec) MarshalJSON(o proto.Message) ([]byte, error)

MarshalJSON implements JSONMarshaler.MarshalJSON method, it marshals to JSON using proto codec.

func (*ProtoCodec) MustMarshalBinaryBare

func (pc *ProtoCodec) MustMarshalBinaryBare(o ProtoMarshaler) []byte

MustMarshalBinaryBare implements BinaryMarshaler.MustMarshalBinaryBare method.

func (*ProtoCodec) MustMarshalBinaryLengthPrefixed

func (pc *ProtoCodec) MustMarshalBinaryLengthPrefixed(o ProtoMarshaler) []byte

MustMarshalBinaryLengthPrefixed implements BinaryMarshaler.MustMarshalBinaryLengthPrefixed method.

func (*ProtoCodec) MustMarshalJSON

func (pc *ProtoCodec) MustMarshalJSON(o proto.Message) []byte

MustMarshalJSON implements JSONMarshaler.MustMarshalJSON method, it executes MarshalJSON except it panics upon failure.

func (*ProtoCodec) MustUnmarshalBinaryBare

func (pc *ProtoCodec) MustUnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler)

MustUnmarshalBinaryBare implements BinaryMarshaler.MustUnmarshalBinaryBare method.

func (*ProtoCodec) MustUnmarshalBinaryLengthPrefixed

func (pc *ProtoCodec) MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler)

MustUnmarshalBinaryLengthPrefixed implements BinaryMarshaler.MustUnmarshalBinaryLengthPrefixed method.

func (*ProtoCodec) MustUnmarshalJSON

func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr proto.Message)

MustUnmarshalJSON implements JSONMarshaler.MustUnmarshalJSON method, it executes UnmarshalJSON except it panics upon failure.

func (*ProtoCodec) UnmarshalBinaryBare

func (pc *ProtoCodec) UnmarshalBinaryBare(bz []byte, ptr ProtoMarshaler) error

UnmarshalBinaryBare implements BinaryMarshaler.UnmarshalBinaryBare method.

func (*ProtoCodec) UnmarshalBinaryLengthPrefixed

func (pc *ProtoCodec) UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error

UnmarshalBinaryLengthPrefixed implements BinaryMarshaler.UnmarshalBinaryLengthPrefixed method.

func (*ProtoCodec) UnmarshalJSON

func (pc *ProtoCodec) UnmarshalJSON(bz []byte, ptr proto.Message) error

UnmarshalJSON implements JSONMarshaler.UnmarshalJSON method, it unmarshals from JSON using proto codec.

func (*ProtoCodec) UnpackAny

func (pc *ProtoCodec) UnpackAny(any *types.Any, iface interface{}) error

UnpackAny implements AnyUnpacker.UnpackAny method, it unpacks the value in any to the interface pointer passed in as iface.

type ProtoMarshaler

type ProtoMarshaler interface {
	proto.Message // for JSON serialization

	Marshal() ([]byte, error)
	MarshalTo(data []byte) (n int, err error)
	MarshalToSizedBuffer(dAtA []byte) (int, error)
	Size() int
	Unmarshal(data []byte) error
}

Directories

Path Synopsis
Package legacy contains a global amino Cdc which is deprecated but still used in several places within the SDK.
Package legacy contains a global amino Cdc which is deprecated but still used in several places within the SDK.
unknownproto implements functionality to "type check" protobuf serialized byte sequences against an expected proto.Message to report: a) Unknown fields in the stream -- this is indicative of mismatched services, perhaps a malicious actor b) Mismatched wire types for a field -- this is indicative of mismatched services Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil { // Handle the error.
unknownproto implements functionality to "type check" protobuf serialized byte sequences against an expected proto.Message to report: a) Unknown fields in the stream -- this is indicative of mismatched services, perhaps a malicious actor b) Mismatched wire types for a field -- this is indicative of mismatched services Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil { // Handle the error.

Jump to

Keyboard shortcuts

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