Struct ebml_iterable::TagWriter[][src]

pub struct TagWriter<W: Write> { /* fields omitted */ }
Expand description

Provides a tool to write EBML files based on Tags. Writes to a destination that implements std::io::Write.

Unlike the TagIterator, this does not require a specification to write data. This writer provides the write_raw() method which can be used to write data that is outside of any specification. The regular write() method can be used to write any TSpec objects regardless of whether they came from a TagIterator or not.

Implementations

Returns a new TagWriter instance.

The dest parameter can be anything that implements std::io::Write.

Write a tag to this instance’s destination.

This method writes a tag from any specification. There are no restrictions on the type of specification being written - it simply needs to implement the EbmlSpecification and EbmlTag traits.

Errors

This method can error if there is a problem writing the input tag. The different possible error states are enumerated in TagWriterError.

Panics

This method can panic if <TSpec> is an internally inconsistent specification (i.e. it claims that a specific tag variant is a specific data type but it is not). This won’t happen if the specification being used was created using the #[ebml_specification] attribute macro.

Examples

use std::fs::File;
use ebml_iterable::TagWriter;
use ebml_iterable::specs::Master;

let mut file = File::create("my_ebml_file.ebml")?;
let mut my_writer = TagWriter::new(&mut file);
my_writer.write(&EmptySpec::with_children(
  0x1a45dfa3, 
  vec![EmptySpec::with_data(0x18538067, &[0x01])])
)?;

Write raw tag data to this instance’s destination.

This method allows writing any tag id with any arbitrary data without using a specification. Specifications should generally provide an Unknown variant to handle arbitrary unknown data which can be written through the regular write() method, so use of this method is typically discouraged.

Errors

This method can error if there is a problem writing the input tag. The different possible error states are enumerated in TagWriterError.

Examples

use std::fs::File;
use ebml_iterable::TagWriter;

let mut file = File::create("my_ebml_file.ebml")?;
let mut my_writer = TagWriter::new(&mut file);
my_writer.write_raw(0x1a45dfa3, &[0x18, 0x53, 0x80, 0x67, 0x81, 0x01])?;

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.