encoding

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package encoding implements compact binary codecs for EasyVCS metadata and trees. It replaces the previous JSON-text/line-text representations, which dominated the SQLite database size (metadata was ~99% of the store). These codecs are dependency-free (standard library) and produce much smaller, faster-to-decode payloads.

To avoid a dependency cycle (store needs encoding to serialize snapshots, while encoding needs store types to encode them), the encode/decode functions operate on primitive/alias types and return the store types only through the store package's own integration layer. Here we define local value types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeRevisionBody

func DecodeRevisionBody(body []byte) (current object.ID, forkFrom string, err error)

DecodeRevisionBody decodes a revision body.

func DecodeTree

func DecodeTree(payload []byte) (*object.Tree, error)

DecodeTree decodes a binary tree.

func EncodeRevisionBody

func EncodeRevisionBody(current object.ID, forkFrom string) []byte

EncodeRevisionBody encodes a revision's current snapshot id and fork_from.

func EncodeSnapshotMeta

func EncodeSnapshotMeta(s BaseSnapshot) []byte

EncodeSnapshotMeta packs parents, author, and description into a compact binary blob (varints + length-prefixed strings).

func EncodeTree

func EncodeTree(t *object.Tree) []byte

EncodeTree binary-encodes a tree: count, then per entry (name, kind, id). This replaces the previous line-text format (name\nkind\nsha\n), which bloat for trees with many files.

Types

type Author

type Author struct {
	Name  string
	Email string
}

Author is a compact alias of the store author value (name/email).

type BaseSnapshot

type BaseSnapshot struct {
	Parents     []object.ID
	Author      Author
	Description string
}

BaseSnapshot is a minimal snapshot view used by encode (id-independent).

type SnapshotMeta

type SnapshotMeta struct {
	Parents     []object.ID
	Author      Author
	Description string
}

SnapshotMeta is the decoded compact snapshot metadata.

func DecodeSnapshotMeta

func DecodeSnapshotMeta(payload []byte) (SnapshotMeta, error)

DecodeSnapshotMeta is the inverse of EncodeSnapshotMeta.

Jump to

Keyboard shortcuts

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