Documentation ¶
Overview ¶
Package pack provides methods to deal with self describing files of proto data.
The file format consists of a magic marker, followed by a Header. After that is a repeated sequence of uvarint length, tag and matching encoded message pair. Some section tags will also be followed by a string. The tag 0 is special, and marks a type entry, the body will be a descriptor.DescriptorProto.
Index ¶
Constants ¶
const ( // Magic is the file magic that prefixes all pack files. Magic = "protopack" // ErrIncorrectMagic is the error returned when the file header is not matched. ErrIncorrectMagic = fault.Const("Incorrect pack magic header") // VersionMajor is the curent major version the package writes. VersionMajor = 1 // VersionMinor is the current minor version the package writes. VersionMinor = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrUnknownType ¶
type ErrUnknownType struct{ TypeName string }
ErrUnknownType is the error returned by Reader.Unmarshal() when it encounters an unknown proto type.
func (ErrUnknownType) Error ¶
func (e ErrUnknownType) Error() string
type ErrUnknownVersion ¶
type ErrUnknownVersion struct{ Version *Version }
ErrUnknownVersion is the error returned when the header version is one this package cannot handle.
func (ErrUnknownVersion) Error ¶
func (e ErrUnknownVersion) Error() string
type Reader ¶
type Reader struct { // Types is the set of registered types this reader will decode. Types *Types // contains filtered or unexported fields }
Reader is the type for a pack file reader. They should only be constructed by NewReader.
type Type ¶
type Type struct { // Name is the cannocial unique name of the type. // This will be the same name as used in the proto registry. Name string // Index is the tag index used for the type in this packfile. Index uint64 // Type is the reflection type that maps to this type registry. Type reflect.Type // Descriptor is the proto description of this type, it is packed // into the file and can be used to reflect on the type. Descriptor *descriptor.DescriptorProto }
Type is an entry in the map of types stored in a packfile.
type Types ¶
type Types struct {
// contains filtered or unexported fields
}
Types stores the full type registry for a packfile. It is exposed so that you can pre-build a cannocial type registry rather than constructing on demand.
func (*Types) AddMessage ¶
AddMessage adds a registry entry for a given message if needed. It returns the registry entry, and a bool that is true if the entry was newly added.
func (*Types) AddName ¶
AddName adds a type by name. It uses the proto type registry to look up the name.
type Writer ¶
type Writer struct { // Types is the set of registered types encoded through this writer. Types *Types // contains filtered or unexported fields }
Writer is the type for a pack file writer. They should only be constructed by NewWriter.