Documentation
¶
Overview ¶
Package ebml implements a simple EBML parser.
The EBML specification is RFC 8794.
Index ¶
- Variables
- func DocTypes() []string
- func Register(docType string, s schema.Schema)
- type Callbacker
- type DecodeSeeker
- type DecodeTypeError
- type Decoder
- func (d *Decoder) AsSeeker() (io.Seeker, bool)
- func (d *Decoder) Decode(el Element, 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
- func (d *Decoder) EndOfUnknownDataSize(parent Element, el Element) bool
- func (d *Decoder) NextOf(parent Element, offset int64) (el Element, n int, err error)
- func (d *Decoder) SetCallback(c Callbacker)
- func (d *Decoder) Skip(el Element) error
- func (d *Decoder) SkipByte() error
- type Def
- type DocTypeExtension
- type EBML
- type Element
- type InvalidDecodeError
- type UnknownDocTypeError
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 DefaultAllocationWindow = int64(1<<24) - 1
var ErrElementOverflow = errors.New("ebml: element overflow")
ErrElementOverflow signals that an element signals a length greater than the parent DataSize.
var ErrInvalidVINTLength = ebmltext.ErrInvalidVINTWidth
var RootEl = Element{DataSize: -1, Schema: schema.Element{Name: "root", Type: TypeMaster}}
var UnknownSchema = schema.Element{ Name: "Unknown element", Documentation: []schema.Documentation{{Content: "The purpose of this object is to signal an error."}}, }
Functions ¶
Types ¶
type Callbacker ¶
type Callbacker interface { // Found is called whenever a new element is found in the target io.Reader. Found(el Element, offset int64, headerSize int) Callbacker // Decoded is called whenever an element is decoded from the target io.Reader. Decoded(el Element, offset int64, headerSize int, val any) Callbacker }
type DecodeSeeker ¶
type DecodeSeeker struct {
// contains filtered or unexported fields
}
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 ¶
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) NextOf ¶
NextOf reads the following element id and data size related to the given parent Element.
When NextOf encounters io.EOF or end-of-element condition, it returns io.EOF.
When NextOf encounters ErrElementOverflow fo known data size, you can skip the parent object, or you can read until the parent ends.
See Next about ErrInvalidVINTLength.
func (*Decoder) SetCallback ¶
func (d *Decoder) SetCallback(c Callbacker)
SetCallback adds a Callbacker which is triggered when NextOf reads element id and data size, and when a value is successfully decoded.
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 UnknownDocTypeError ¶
type UnknownDocTypeError struct {
DocType string
}
func (UnknownDocTypeError) Error ¶
func (e UnknownDocTypeError) Error() string
Directories
¶
Path | Synopsis |
---|---|
Package ebmltext provides a low level API to interacts with EBML documents.
|
Package ebmltext provides a low level API to interacts with EBML documents. |
Package schema contains structs for reading xml definitions for ebml schema.
|
Package schema contains structs for reading xml definitions for ebml schema. |