Documentation
¶
Overview ¶
Package object implements content-addressed immutable objects.
Objects are identified by a BLAKE3 hash of their encoded form. This gives content addressing: identical content always maps to the same id, so objects can be deduplicated and stored immutably. An object is either a Blob (file bytes), a Tree (a directory listing of named entries), or a Conflict.
Index ¶
- func BlobToString(data []byte) string
- func EncodeObject(o *Object) ([]byte, error)
- func EncodeTreeBytes(t *Tree) []byte
- func IsConflictObject(k Kind) bool
- func IsConflictPayload(payload []byte) bool
- func RandomRevisionID() (string, error)
- type Conflict
- type Entry
- type ID
- type Kind
- type Object
- type Term
- type Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlobToString ¶
BlobToString is a small helper used for debug rendering of blob contents.
func EncodeObject ¶
EncodeObject serializes an object into its canonical byte form used for storage. It is the inverse of DecodeObject. Trees use the compact binary encoding; blob content is raw bytes.
func EncodeTreeBytes ¶
EncodeTreeBytes binary-encodes a tree (compact: varint count + per-entry name/kind/id). It replaces the old line-text form which bloat for trees with many files. The encoded payload is prefixed with the treeMagic marker so a blob can be distinguished from a tree without ambiguity.
func IsConflictObject ¶
IsConflictObject reports whether an object kind is a conflict.
func IsConflictPayload ¶
IsConflictPayload reports whether a payload looks like an encoded conflict.
func RandomRevisionID ¶
RandomRevisionID returns a random 16-byte revision id encoded as 32 hex chars. revision ids are generated once and never change (content-independent), unlike object ids which are derived from content.
Types ¶
type Conflict ¶
Conflict is an N-way merge conflict, expressed as a set of negative terms (the base versions, "removes") and positive terms (the side versions, "adds"). This mirrors jj's `Merge<T>` where a 3-way conflict is represented as [-base, +ours, +theirs]; a conflict can generalize to any number of terms. Each term references a blob id plus a human label describing where it came from.
func NewConflictFrom3Way ¶
NewConflictFrom3Way builds a conflict from a classic 3-way merge: base is negative; ours and theirs are positive.
type ID ¶
type ID [32]byte
ID is a content-addressed object identifier (32-byte BLAKE3 digest).
func HashID ¶
HashID computes the content id of an object. The optional context is mixed into the hash so callers can namespace hashes if needed.
type Object ¶
Object is a decoded immutable object.
func DecodeObject ¶
DecodeObject parses the canonical byte form back into an Object. id is the content id the caller expects; it is recorded on the object so callers can sanity check. Trees are recognized by the presence of the compact binary encoding (whose first field is a varint); blob content is passed through.
type Tree ¶
Tree is a directory: a sorted map of entry name -> entry.
func DecodeTreeBytes ¶
DecodeTreeBytes decodes a binary tree. It expects the payload WITHOUT the treeMagic prefix (callers strip it after detection).
func (*Tree) SortedEntries ¶
SortedEntries returns the entries in lexicographical order.