Crates.io | ebml-iterable |
lib.rs | ebml-iterable |
version | |
source | src |
created_at | 2021-06-02 19:57:38.763034 |
updated_at | 2024-12-12 19:44:36.972973 |
description | This crate provides an iterator over EBML encoded data. The items provided by the iterator are Tags as defined in EBML. The iterator is spec-agnostic and requires a specification implementing specific traits to read files. Typically, you would only use this crate to implement a custom specification - most often you would prefer a crate providing an existing specification, like `webm-iterable`. |
homepage | https://github.com/austinleroy/ebml-iterable |
repository | https://github.com/austinleroy/ebml-iterable |
max_upload_size | |
id | 405470 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
EBML stands for Extensible Binary Meta-Language and is somewhat of a binary version of XML. It's used for container formats like WebM or MKV.
IMPORTANT: The iterator contained in this crate is spec-agnostic and requires a specification implementing the
EbmlSpecification
andEbmlTag
traits to read files. Typically, you would only use this crate to implement a custom specification - most often you would prefer a crate providing an existing specification, like webm-iterable.
[dependencies]
ebml-iterable = "0.6.3"
The TagIterator
struct implements Rust's standard Iterator trait.
This struct can be created with the new
function on any source that implements the standard Read trait. The iterator outputs TSpec
objects based on the defined specification and the tag data.
Note: The
with_capacity
method can be used to construct aTagIterator
with a specified default buffer size. This is only useful as a microoptimization to memory management if you know the maximum tag size of the file you're reading.
The data in the tag can then be modified as desired (encryption, compression, etc.) and reencoded using the TagWriter
struct. This struct can be created with the new
function on any source that implements the standard Write trait. Once created, this struct can encode EBML using the write
method on any objects that implement EbmlSpecification
and EbmlTag
regardless of whether they came from a TagIterator
. This will emit binary EBML to the underlying Write
destination.
Most tag types contain their data directly, but there is a category of tag in EBML called Master
which contains other tags. This crate contains an enumeration of three different classifications of master tags:
Start
is a marker for the beginning of a "master" tag.End
is a marker for the end of a "master" tag.Full(children)
is a complete tag that includes all child tags of the Master
tag. This is only emitted by the TagIterator
for tag types passed in via tags_to_buffer
.pub enum TagDataType {
Master,
UnsignedInt,
Integer,
Utf8,
Binary,
Float,
}
TagDataType is an enum containing the possible data types stored within a tag. The relationship between the tag variant and the type of data contained in the tag directly corresponds is defined by whichever specification is in use. Because EBML is binary, the correct specification is required to parse tag content.
Note: This library made a conscious decision to not parse "Date" elements from EBML due to lack of built-in support for dates in Rust. Specification implementations should treat Date elements as Binary so that consumers have the option of parsing the unaltered data using their library of choice, if needed.
Any specification based on EBML can use this library to parse or write binary data. Writing needs nothing special (if you use the write_raw()
method), but parsing requires a struct implementing the EbmlSpecification
and EbmlTag
traits. These traits currently have a large number of methods to implement and need consistent implementations to avoid errors, so any implementation attempt is recommended to use the "derive-spec"
feature flag in this crate and using the provided macro. Custom specification implementations can refer to webm-iterable as an example.
There is currently only one optional feature in this crate, but that may change over time as needs arise.
derive-spec -
When enabled, this provides a macro to simplify implementations of the EbmlSpecification
and EbmlTag
traits. This introduces dependencies on syn
, quote
, and proc-macro2
, so expect compile times to increase a little.
Parsing and writing complete files should both work. Streaming (using tags of unknown size) should now also be supported, as of version 0.4.0. If something is broken, please create an issue.
Any additional feature requests can also be submitted as an issue.