Documentation ¶
Overview ¶
Package ebml implements a simple EBML parser.
The EBML specification is RFC 8794.
Index ¶
- Variables
- func DocTypes() []string
- func ReadElementID(r io.Reader, maxIDLength uint) (id schema.ElementID, n int, err error)
- func Register(docType string, s schema.Schema)
- type DataSize
- type DecodeTypeError
- type Decoder
- func (d *Decoder) Decode(v interface{}) error
- func (d *Decoder) DecodeBody(v interface{}) error
- func (d *Decoder) DecodeHeader() (*EBML, error)
- func (d *Decoder) EndOfKnownDataSize(parent Element, offset int64) (bool, error)
- func (d *Decoder) EndOfUnknownDataSize(parent Element, el Element) (bool, error)
- func (d *Decoder) Next() (el Element, n int, err error)
- func (d *Decoder) NextOf(parent Element, offset int64) (el Element, n int, err error)
- func (d *Decoder) Seek(offset int64, whence int) (ret int64, err error)
- type Def
- type DocTypeExtension
- type EBML
- type Element
- type InvalidDecodeError
- type Reader
- type UnknownDefinitionError
- type UnknownDocTypeError
- type UnknownElementError
Constants ¶
This section is empty.
Variables ¶
var ( IDEBML schema.ElementID = 0x1a45dfa3 IDEBMLVersion schema.ElementID = 0x4286 IDEBMLReadVersion schema.ElementID = 0x42f7 IDEBMLMaxIDLength schema.ElementID = 0x42f2 IDEBMLMaxSizeLength schema.ElementID = 0x42f3 IDDocType schema.ElementID = 0x4282 IDDocTypeVersion schema.ElementID = 0x4287 IDDocTypeReadVersion schema.ElementID = 0x4285 IDDocTypeExtension schema.ElementID = 0x4281 IDDocTypeExtensionName schema.ElementID = 0x4283 IDDocTypeExtensionVersion schema.ElementID = 0x4284 IDVoid schema.ElementID = 0xec IDCRC32 schema.ElementID = 0xbf )
var ( HeaderDef *Def DefaultMaxIDLength uint = 4 DefaultMaxSizeLength uint = 8 )
var ( TypeInteger = "integer" TypeUinteger = "uinteger" TypeFloat = "float" TypeString = "string" TypeDate = "date" TypeUTF8 = "utf-8" TypeMaster = "master" TypeBinary = "binary" )
var ErrElementOverflow = errors.New("ebml: element overflow")
ErrElementOverflow signals that an element signals a length greater than the parent DataSize.
var ErrInvalidVINTLength = fmt.Errorf("ebml: invalid length descriptor")
Functions ¶
func DocTypes ¶
func DocTypes() []string
DocTypes returns a sorted list of the names of the registered document types.
func ReadElementID ¶
ReadElementID reads an Element ID based on https://datatracker.ietf.org/doc/html/rfc8794#section-5
Types ¶
type DataSize ¶
type DataSize struct {
// contains filtered or unexported fields
}
func NewKnownDataSize ¶
func ReadElementDataSize ¶
ReadElementDataSize reads an Element ID based on https://datatracker.ietf.org/doc/html/rfc8794#section-6
type DecodeTypeError ¶
type DecodeTypeError struct { EBMLType string // description of EBML type - "integer", "binary", "master" Type reflect.Type // type of Go value it could not be assigned to Offset int64 // error occurred after reading Offset bytes Path string // the full path from root node to the field }
An DecodeTypeError describes an EBML value that was not appropriate for a value of a specific Go type.
func (*DecodeTypeError) Error ¶
func (e *DecodeTypeError) Error() string
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder represents an EBML parser reading a particular input stream.
func NewDecoder ¶
func NewDecoder(r io.ReadSeeker) *Decoder
NewDecoder reads and parses an EBML Document from r.
func (*Decoder) DecodeBody ¶
DecodeBody decodes the EBML Body and stores the result in the value pointed to by v. If v is nil or not a pointer, DecodeBody returns an InvalidDecodeError.
func (*Decoder) DecodeHeader ¶
DecodeHeader decodes the document header.
func (*Decoder) EndOfKnownDataSize ¶
EndOfKnownDataSize tries to guess the end of an element which has a know data size.
A parent with unknown data size won't raise an error but not handled as the end of the parent.
func (*Decoder) EndOfUnknownDataSize ¶
EndOfUnknownDataSize tries to guess the end of an element which has an unknown data size.
A parent with known data size won't raise an error but not handled as the end of the parent.
func (*Decoder) Next ¶
Next reads the following element id and data size. It must be called before Decode.
type Def ¶
func Definition ¶
type DocTypeExtension ¶
type InvalidDecodeError ¶
An InvalidDecodeError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)
func (*InvalidDecodeError) Error ¶
func (e *InvalidDecodeError) Error() string
type Reader ¶
type Reader struct { // https://tools.ietf.org/html/rfc8794#section-11.2.4 MaxIDLength uint // https://tools.ietf.org/html/rfc8794#section-11.2.5 MaxSizeLength uint // contains filtered or unexported fields }
Reader provides a low level API to interacts with EBML documents. Use directly with caution.
func NewReader ¶
func NewReader(r io.ReadSeeker) *Reader
type UnknownDefinitionError ¶
type UnknownDefinitionError struct {
// contains filtered or unexported fields
}
func (UnknownDefinitionError) Error ¶
func (u UnknownDefinitionError) Error() string
func (UnknownDefinitionError) ID ¶
func (u UnknownDefinitionError) ID() schema.ElementID
type UnknownDocTypeError ¶
type UnknownDocTypeError struct {
DocType string
}
func (UnknownDocTypeError) Error ¶
func (e UnknownDocTypeError) Error() string
type UnknownElementError ¶
type UnknownElementError struct {
// contains filtered or unexported fields
}
func (UnknownElementError) Error ¶
func (e UnknownElementError) Error() string