codec

package
v0.0.0-...-689c838 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_codec_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type BinaryCodec

type BinaryCodec interface {
	Marshal(message any) ([]byte, error)
	Unmarshal(data []byte, ptr any) error
	ToAny(proto.Message) (*anypb.Any, error)
	FromAny(*anypb.Any) (proto.Message, error)
}

BinaryCodec is an interface model that defines the requirements for binary encoding and decoding A binary encoder converts data into a compact, non-human-readable binary format, which is highly efficient in terms of both storage size and speed for serialization and deserialization

type JSONCodec

type JSONCodec interface {
	json.Marshaler
	json.Unmarshaler
}

JSONCodec is an interface model that defines requirements for json encoding and decoding converts data into a human-readable text format (JSON) which can be more friendly but less performant

type Protobuf

type Protobuf struct{}

Protobuf is an encoding implementation for protobuf

func (*Protobuf) FromAny

func (p *Protobuf) FromAny(any *anypb.Any) (proto.Message, error)

FromAny() converts a proto any to the protobuf message

func (*Protobuf) Marshal

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

Marshal() converts a message to bytes

func (*Protobuf) ToAny

func (p *Protobuf) ToAny(message proto.Message) (*anypb.Any, error)

ToAny() packs a protobuf message to a generic any

func (*Protobuf) Unmarshal

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

Unmarshal() converts bytes to a protobuf structure

type Test

type Test struct {
	I uint64 `protobuf:"varint,1,opt,name=i,proto3" json:"i,omitempty"`
	// contains filtered or unexported fields
}

***************************************************************************************************** This file is auto-generated from source files in `/lib/.proto/*` using Protocol Buffers (protobuf)

Protobuf is a language-neutral, platform-neutral serialization format. It allows users to define objects in a way that’s both efficient to store and fast to transmit over the network. These definitions are compiled into code that *enables different systems and programming languages to communicate in a byte-perfect manner*

To update these structures, make changes to the source .proto files, then recompile to regenerate this file. These auto-generated files are easily recognized by checking for a `.pb.go` ending ***************************************************************************************************** _ _ _ Test is a structure purely used to test the 'codec' package

func (*Test) Descriptor deprecated

func (*Test) Descriptor() ([]byte, []int)

Deprecated: Use Test.ProtoReflect.Descriptor instead.

func (*Test) GetI

func (x *Test) GetI() uint64

func (*Test) ProtoMessage

func (*Test) ProtoMessage()

func (*Test) ProtoReflect

func (x *Test) ProtoReflect() protoreflect.Message

func (*Test) Reset

func (x *Test) Reset()

func (*Test) String

func (x *Test) String() string

Jump to

Keyboard shortcuts

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