[][src]Trait binjs::io::FileStructurePrinter

pub trait FileStructurePrinter {
    fn enable_file_structure_print(&mut self) { ... }
fn disable_file_structure_print(&mut self) { ... }
fn is_file_structure_print_enabled(&mut self) -> bool { ... }
fn prepare_file_structure_column(&mut self) { ... }
fn newline_for_file_structure_print(&mut self) { ... } }

An API for printing the binary representation and its structural interpretation of the file.

A struct which implements this trait is supposed to print the binary representation of the file in the first column internally, and print the structural interpretation in the second column, which is triggered by print_file_structure!() macro below, from various places that interprets the file structure.

This example is not tested
(first column)   (second column)
01             # Script {
08             # AssertedScriptGlobalScope {
02             # list (length=0) [
...            # ...

Default no-op implementations are provided for all methods, which can be used by the following declaration:

This example is not tested
impl FileStructurePrinter for T {}

Provided methods

fn enable_file_structure_print(&mut self)

Enables printing the binary representation and the structural interpretation.

fn disable_file_structure_print(&mut self)

Disables printing the binary representation and the structural interpretation.

fn is_file_structure_print_enabled(&mut self) -> bool

True if file structure print is enabled. With default implementation, nothing is printed.

fn prepare_file_structure_column(&mut self)

Prints the column separator ("# " characters), and padding before it if necessary.

Before calling this method, the output is supposed to be the following:

This example is not tested
00 01 02<= cursor position

After calling this method, the output is supposed to be the following:

This example is not tested
00 01 02     # <= cursor position

The column width is not defined but the implementation is supposed to keep the same column width through the entire output, regardless of the number of bytes it reads for each line.

fn newline_for_file_structure_print(&mut self)

Prints newline after printing the structural interpretation column. The implementation is supposed to print newline character(s) and also reset the current column position internally, in order to print the right number of spaces in prepare_file_structure_column.

Before calling this method, the output is supposed to be the following:

This example is not tested
00 01 02     # string="hello"<= cursor position

After calling this method, the output is supposed to be the following:

This example is not tested
00 01 02     # string="hello"
<= cursor position
Loading content...

Implementors

impl FileStructurePrinter for binjs::io::entropy::read::Decoder[src]

impl FileStructurePrinter for binjs::io::multipart::TreeTokenReader[src]

impl<R> FileStructurePrinter for binjs::io::binjs_json::read::Decoder<R> where
    R: Read
[src]

impl<R> FileStructurePrinter for binjs::io::simple::TreeTokenReader<R> where
    R: Read + Seek
[src]

Loading content...