Documentation ¶
Overview ¶
This package implements the C4 ID system **SMPTE standard ST 2114:2017**. C4 IDs are a universally unique and consistent identifiers standardize the derivation and formatting of data identification so that all users independently agree on the identification of any given block or set of blocks of data.
C4 IDs are 90 character long strings suitable for use in filenames, URLs, database fields, or anywhere else that a string identifier might normally be used.
In ram C4 IDs are represented in a 64 byte "digest" format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ID ¶
type ID [64]byte
// Encoder generates an ID for a contiguous bock of data.
type Encoder struct { err error h hash.Hash }
// NewIDEncoder makes a new Encoder.
func NewEncoder() *Encoder { return &Encoder{ h: sha512.New(), } }
// Write writes bytes to the hash that makes up the ID.
func (e *Encoder) Write(b []byte) (int, error) { return e.h.Write(b) }
// ID returns the ID for the bytes written so far.
func (e *Encoder) ID() (id ID) { copy(id[:], e.h.Sum(nil)) return id }
// Reset the encoder so it can identify a new block of data.
func (e *Encoder) Reset() { e.h.Reset() }
ID represents a C4 ID.
func (ID) Cmp ¶
Cmp compares two IDs. There are 3 possible return values.
-1 : Argument id is less than calling id.
0 : Argument id and calling id are identical.
+1 : Argument id is greater than calling id.
Comparison is done on the actual numerical value of the ids. Not the string representation.
func (ID) MarshalJSON ¶
func (*ID) UnmarshalJSON ¶
type Identifiable ¶
type Identifiable interface {
ID() ID
}
Identifiable is an interface that requires an ID() method that returns the c4 ID of the of the object.
type Tree ¶
type Tree []byte
`Tree` implements an ID tree as used for calculating IDs of non-contiguous sets of data. A C4 ID Tree is a type of merkle tree except that the list of IDs is sorted. According to the standard this is done to insure that two identical lists of IDs always resolve to the same ID.
func NewTree ¶
NewTree creates a new Tree from a DigestSlice, and copies the digests into the tree. However, it does not compute the tree.