codec

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GobCodec

type GobCodec struct{}

GobCodec implements the Codec interface using encoding/gob for serialization. Provides efficient binary encoding/decoding with proper handling of nil and zero values. Note: gob requires types to be registered for interface{} encoding.

func (GobCodec) Decode

func (c GobCodec) Decode(data []byte, v any) error

Decode deserializes gob bytes into the provided value pointer. Returns nil error for nil data (leaves v unchanged). The v parameter must be a pointer to the target type.

func (GobCodec) Encode

func (c GobCodec) Encode(v any) ([]byte, error)

Encode serializes a value to gob bytes. Returns nil bytes for nil input values. Handles zero values according to gob marshaling rules.

type JSONCodec

type JSONCodec struct{}

JSONCodec implements the Codec interface using encoding/json for serialization. Provides standard JSON encoding/decoding with proper handling of nil and zero values.

func (JSONCodec) Decode

func (c JSONCodec) Decode(data []byte, v any) error

Decode deserializes JSON bytes into the provided value pointer. Returns nil error for nil data (leaves v unchanged). The v parameter must be a pointer to the target type.

func (JSONCodec) Encode

func (c JSONCodec) Encode(v any) ([]byte, error)

Encode serializes a value to JSON bytes. Returns nil bytes for nil input values. Handles zero values according to JSON marshaling rules.

type MessagePackCodec

type MessagePackCodec struct{}

MessagePackCodec implements the Codec interface using MessagePack for serialization. Provides efficient binary encoding/decoding with proper handling of nil and zero values.

func (MessagePackCodec) Decode

func (c MessagePackCodec) Decode(data []byte, v any) error

Decode deserializes MessagePack bytes into the provided value pointer. Returns nil error for nil data (leaves v unchanged). The v parameter must be a pointer to the target type.

func (MessagePackCodec) Encode

func (c MessagePackCodec) Encode(v any) ([]byte, error)

Encode serializes a value to MessagePack bytes. Returns nil bytes for nil input values. Handles zero values according to MessagePack marshaling rules.

Jump to

Keyboard shortcuts

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