codec

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 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 AvroBinaryCodec

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

AvroBinaryCodec is a Codec implementation for encoding and decoding with avro schema in binary format.

func NewAvroBinaryCodec

func NewAvroBinaryCodec(schemaDefinition string) (*AvroBinaryCodec, error)

NewAvroBinaryCodec returns a new AvroBinaryCodec instance.

func (*AvroBinaryCodec) Decode

func (c *AvroBinaryCodec) Decode(enc []byte, out any) error

Decode decodes from avro binary format the provided input.

func (*AvroBinaryCodec) Encode

func (c *AvroBinaryCodec) Encode(in any) ([]byte, error)

Encode encodes in avro binary format the provided input.

type AvroJsonCodec

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

AvroJsonCodec is a Codec implementation for encoding and decoding with avro schema in json format.

func NewAvroJsonCodec

func NewAvroJsonCodec(schemaDefinition string) (*AvroJsonCodec, error)

NewAvroJsonCodec returns a new AvroJsonCodec instance.

func (*AvroJsonCodec) Decode

func (c *AvroJsonCodec) Decode(enc []byte, out any) error

Decode decodes from avro json format.

func (*AvroJsonCodec) Encode

func (c *AvroJsonCodec) Encode(in any) ([]byte, error)

Encode encodes in avro json format.

type Codec

type Codec interface {
	Encode(in any) ([]byte, error)
	Decode(enc []byte, out any) error
}

Codec is the interface for codecs in charge to handle encoding and decoding.

type CodecFactory

type CodecFactory interface {
	Create(schemaType pubsub.SchemaType, schemaEncoding pubsub.SchemaEncoding, schemaDefinition string) (Codec, error)
}

CodecFactory is the interface for Codec factories.

type DefaultCodecFactory

type DefaultCodecFactory struct{}

DefaultCodecFactory is the default CodecFactory implementation.

func NewDefaultCodecFactory

func NewDefaultCodecFactory() *DefaultCodecFactory

NewDefaultCodecFactory returns a new DefaultCodecFactory instance.

func (*DefaultCodecFactory) Create

func (f *DefaultCodecFactory) Create(schemaType pubsub.SchemaType, schemaEncoding pubsub.SchemaEncoding, schemaDefinition string) (Codec, error)

Create creates a new Codec for given schema type, encoding and definition.

type ProtoBinaryCodec

type ProtoBinaryCodec struct {
}

ProtoBinaryCodec is a Codec implementation for encoding and decoding with protobuf schema in binary format.

func NewProtoBinaryCodec

func NewProtoBinaryCodec() *ProtoBinaryCodec

NewProtoBinaryCodec returns a new ProtoBinaryCodec instance.

func (*ProtoBinaryCodec) Decode

func (c *ProtoBinaryCodec) Decode(enc []byte, out any) error

Decode decodes from protobuf binary format the provided input.

func (*ProtoBinaryCodec) Encode

func (c *ProtoBinaryCodec) Encode(in any) ([]byte, error)

Encode encodes in protobuf binary format the provided input.

type ProtoJsonCodec

type ProtoJsonCodec struct{}

ProtoJsonCodec is a Codec implementation for encoding and decoding with protobuf schema in json format.

func NewProtoJsonCodec

func NewProtoJsonCodec() *ProtoJsonCodec

NewProtoJsonCodec returns a new ProtoJsonCodec instance.

func (*ProtoJsonCodec) Decode

func (c *ProtoJsonCodec) Decode(enc []byte, out any) error

Decode decodes from protobuf json format.

func (*ProtoJsonCodec) Encode

func (c *ProtoJsonCodec) Encode(in any) ([]byte, error)

Encode encodes in protobuf json format.

type RawCodec

type RawCodec struct{}

RawCodec is a Codec implementation for encoding and decoding without specified schemas.

func NewRawCodec

func NewRawCodec() *RawCodec

NewRawCodec returns a new RawCodec instance.

func (*RawCodec) Decode

func (c *RawCodec) Decode([]byte, any) error

Decode returns a error.

func (*RawCodec) Encode

func (c *RawCodec) Encode(in any) ([]byte, error)

Encode encodes in []byte.

Jump to

Keyboard shortcuts

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