Trait webm_iterable::matroska_spec::EbmlSpecification [−]
pub trait EbmlSpecification<T> where
T: EbmlSpecification<T> + EbmlTag<T> + Clone, { fn get_tag_data_type(id: u64) -> TagDataType; fn get_unsigned_int_tag(id: u64, data: u64) -> Option<T>; fn get_signed_int_tag(id: u64, data: i64) -> Option<T>; fn get_utf8_tag(id: u64, data: String) -> Option<T>; fn get_binary_tag(id: u64, data: &[u8]) -> Option<T>; fn get_float_tag(id: u64, data: f64) -> Option<T>; fn get_master_tag(id: u64, data: Master<T>) -> Option<T>; fn get_raw_tag(id: u64, data: &[u8]) -> T; fn get_tag_id(item: &T) -> u64 { ... } }
Expand description
This trait, along with EbmlTag
, should be implemented to define a specification so that EBML can be parsed correctly. Typically implemented on an Enum of tag variants.
Any specification using EBML can take advantage of this library to parse or write binary data. As stated in the docs, TagWriter
needs nothing special if you stick with the write_raw
method, but TagIterator
requires a struct implementing this trait. Custom specification implementations can refer to webm-iterable as an example.
This trait and EbmlTag
are typically implemented simultaneously. They are separate traits as they have primarily different uses - EbmlSpecification
should be brought into scope when dealing with the specification as a whole, whereas EbmlTag
should be brought into scope when dealing with specific tags.
Required methods
fn get_tag_data_type(id: u64) -> TagDataType
fn get_tag_data_type(id: u64) -> TagDataType
Pulls the data type for a tag from the spec, based on the tag id.
This function must return TagDataType::Binary
if the input id is not in the specification. Implementors can reference webm-iterable for an example.
fn get_unsigned_int_tag(id: u64, data: u64) -> Option<T>
fn get_unsigned_int_tag(id: u64, data: u64) -> Option<T>
Creates an unsigned integer type tag from the spec.
This function must return None
if the input id is not in the specification or if the input id data type is not TagDataType::UnsignedInt
. Implementors can reference webm-iterable for an example.
fn get_signed_int_tag(id: u64, data: i64) -> Option<T>
fn get_signed_int_tag(id: u64, data: i64) -> Option<T>
Creates a signed integer type tag from the spec.
This function must return None
if the input id is not in the specification or if the input id data type is not TagDataType::Integer
. Implementors can reference webm-iterable for an example.
fn get_utf8_tag(id: u64, data: String) -> Option<T>
fn get_utf8_tag(id: u64, data: String) -> Option<T>
Creates a utf8 type tag from the spec.
This function must return None
if the input id is not in the specification or if the input id data type is not TagDataType::Utf8
. Implementors can reference webm-iterable for an example.
Creates a binary type tag from the spec.
This function must return None
if the input id is not in the specification or if the input id data type is not TagDataType::Binary
. Implementors can reference webm-iterable for an example.
fn get_float_tag(id: u64, data: f64) -> Option<T>
fn get_float_tag(id: u64, data: f64) -> Option<T>
Creates a float type tag from the spec.
This function must return None
if the input id is not in the specification or if the input id data type is not TagDataType::Float
. Implementors can reference webm-iterable for an example.
fn get_master_tag(id: u64, data: Master<T>) -> Option<T>
fn get_master_tag(id: u64, data: Master<T>) -> Option<T>
Creates a master type tag from the spec.
This function must return None
if the input id is not in the specification or if the input id data type is not TagDataType::Master
. Implementors can reference webm-iterable for an example.
fn get_raw_tag(id: u64, data: &[u8]) -> T
fn get_raw_tag(id: u64, data: &[u8]) -> T
Creates a tag that does not conform to the spec.
This function should return a “RawTag” variant that contains the tag id and tag data. Tag data should only be retrievable as binary data. Implementors can reference webm-iterable for an example.
Provided methods
fn get_tag_id(item: &T) -> u64
fn get_tag_id(item: &T) -> u64
Gets the id of a specific tag variant.
Default implementation uses the EbmlTag
implementation. Implementors can reference webm-iterable for an example.
Implementations on Foreign Types
impl EbmlSpecification<EmptySpec> for EmptySpec
impl EbmlSpecification<EmptySpec> for EmptySpec
pub fn get_tag_data_type(_id: u64) -> TagDataType
pub fn get_unsigned_int_tag(_id: u64, _data: u64) -> Option<EmptySpec>
pub fn get_signed_int_tag(_id: u64, _data: i64) -> Option<EmptySpec>
pub fn get_utf8_tag(_id: u64, _data: String) -> Option<EmptySpec>
pub fn get_float_tag(_id: u64, _data: f64) -> Option<EmptySpec>
pub fn get_master_tag(id: u64, data: Master<EmptySpec>) -> Option<EmptySpec>
pub fn get_raw_tag(id: u64, data: &[u8]) -> EmptySpec