serialization

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package serialization provides compact binary serialization for deterministic encryption.

Supported Types:

  • Numeric: int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64
  • Floating Point: float32, float64
  • Boolean: bool
  • Text: string
  • Binary: []byte
  • Collections: []string
  • Temporal: time.Time
  • Arrays: [N]byte (converted to []byte format)
  • Pointers: *T for any supported type T (with nil handling)
  • Type Aliases: Custom types based on supported types (e.g., type UserID int64, type Tags []string)

Binary Format:

  • Fixed-size types (int, float, bool): Direct little-endian encoding
  • Variable-length types (string, []byte, []string): [4-byte length prefix][data]
  • []string: [4-byte slice length][string1: 4-byte length + UTF-8 bytes][string2: ...]
  • Pointers: [1-byte nil marker (0x00=nil, 0x01=non-nil)][serialized value if non-nil]

The serialization is deterministic: the same input always produces identical bytes, which is critical for searchable encryption and consistent hashing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize(data []byte, target any) error

Deserialize converts bytes back to a value of the specified type. The caller must specify the expected type.

func Serialize

func Serialize(value any) ([]byte, error)

Serialize converts a value to bytes using a compact binary format. This is optimized for deterministic output and performance.

Types

This section is empty.

Jump to

Keyboard shortcuts

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