cserializer

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSON

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

JSON implements the shared body codec for ordinary Go values and protobuf messages.

func NewJSON

func NewJSON() *JSON

NewJSON creates a codec for ordinary structs and canonical ProtoJSON messages.

func (*JSON) ID added in v1.0.20

func (j *JSON) ID() int32

ID returns the stable AGP JSON codec ID.

func (*JSON) Marshal

func (j *JSON) Marshal(v any) ([]byte, error)

Marshal uses canonical ProtoJSON for protobuf messages and jsoniter for plain structs.

func (*JSON) Name

func (j *JSON) Name() string

Name returns the codec name.

func (*JSON) Unmarshal

func (j *JSON) Unmarshal(data []byte, v any) error

Unmarshal uses canonical ProtoJSON for protobuf messages and jsoniter for plain structs.

type Protobuf

type Protobuf struct{}

Protobuf serializes concrete generated protobuf messages.

func NewProtobuf

func NewProtobuf() *Protobuf

NewProtobuf creates the binary protobuf body codec.

func (*Protobuf) ID added in v1.0.20

func (p *Protobuf) ID() int32

ID returns the stable AGP protobuf codec ID.

func (*Protobuf) Marshal

func (p *Protobuf) Marshal(v any) ([]byte, error)

Marshal encodes a concrete protobuf message.

func (*Protobuf) Name

func (p *Protobuf) Name() string

Name returns the codec name.

func (*Protobuf) Unmarshal

func (p *Protobuf) Unmarshal(data []byte, v any) error

Unmarshal decodes into a concrete protobuf message.

type Registry added in v1.0.20

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

Registry is the application-scoped allow-list of protocol body codecs.

func NewRegistry added in v1.0.20

func NewRegistry(codecs ...cfacade.IBodyCodec) *Registry

NewRegistry creates a registry and fails fast on conflicting built-in codecs. When protobuf is registered it becomes the default codec.

func (*Registry) Default added in v1.0.20

func (r *Registry) Default() int32

Default returns the codec id used when a call does not specify one.

func (*Registry) Lookup added in v1.0.20

func (r *Registry) Lookup(id int32) (cfacade.IBodyCodec, bool)

Lookup returns the codec registered for id.

func (*Registry) Marshal added in v1.0.20

func (r *Registry) Marshal(id int32, value any) ([]byte, error)

Marshal encodes a concrete request, response or notification body.

func (*Registry) Register added in v1.0.20

func (r *Registry) Register(codec cfacade.IBodyCodec) error

Register adds or replaces a codec with the same ID and name. Reusing an ID for a different encoding is rejected because codec IDs are wire values.

func (*Registry) SetDefault added in v1.0.20

func (r *Registry) SetDefault(id int32) error

SetDefault selects the default codec. The id must already be registered.

func (*Registry) Unmarshal added in v1.0.20

func (r *Registry) Unmarshal(id int32, data []byte, value any) error

Unmarshal decodes a body using the codec selected by the packet.

Jump to

Keyboard shortcuts

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