A binary format for Hex's registry file, designed for compactness, easy extension and backwards compatibility.
The file begins with the <<72, 69, 88>>
header, following the headers is a number of
sections. A section has a defined layout made of fields, a field is a single named value
with a type defining the field's size and how to interpret it.
All sections beginswith a single INT8
field signifying the type of section followed
by an INT16
field specifying the length of the section excluding the first INT8
and length.
New fields may be added to the end of a section in the future so clients should only read the fields of a section it knows about to maintain backwards compatibility. If there is data left in the section after the client has read the known fields that data should be skipped until the end of the section. This way new fields can be added to sections without breaking existing clients.
Additionally, to ensure backwards compatibility, clients should ignore and skip section types that are not known to it.
Immediately following the header is the INIT
section, unlike the other sections this
section will appear only once. It holds the registry version and
the log file rebuild counter and size, see the log file endpoint specification for details.
The major version is incremented for breaking changes, the minor for non breaking changes.
After the INIT
section there is no inherent ordering between sections, except that
a DEPENDENCY
section belongs to the latest defined RELEASE
which belongs to
the latest defined PACKAGE
. Other section types may be interspersed between
these sections.
If an unsupported major version is found the client should stop and inform the user.
Below are the section layouts:
INIT <<0>>
INT16 (length of section)
INT8 (version number major)
INT8 (version number minor)
INT16 (log file rebuild counter)
INT32 (log file size in bytes)
BIN[64] (log file checksum)
MIX CLIENT RELEASE <<1>> - Used by the Mix client to inform users of new releases
INT16 (length of section)
STRING (version)
STRING (minimum elixir version)
PACKAGE <<2>> - Package definition
INT16 (length of section)
INT32 (package id) (1.)
STRING (package name)
RELEASE <<3>> - A package release
INT16 (length of section)
STRING (version)
BIN[32] (checksum)
ARRAY[STRING] (build tools)
DEPENDENCY <<4>> - A dependency of a package release
INT16 (length of section)
INT32 (package id)
STRING (requirement)
STRING (application name)
BOOL (optional)
The types:
INT8: <<value>>
INT16: <<value::integer-size(16)>>
INT32: <<value::integer-size(32)>>
STRING: <<size, value::binary-size(size)>> (2.)
BIN[size]: <<value::binary-size(size)>>
BOOL: <<0>> | <<1>>
ARRAY[type]: <<num_elements, ...>> (3.)
All integers are unsigned.
-
Package ids are unique for the repository hosting the registry.
-
Strings are UTF8 encoded and has a maximum size of 255 bytes.
-
An array starts with a single
INT8
specifying the number of elements in the array and has a maximum 255 number of elements. Following theINT8
are the elements in the array. The elements' types are defined bytype
inARRAY[type]
.