[−][src]Trait binjs_io::io::TokenWriter
Build an in-memory representation of a BinTree.
Implementations may for instance introduce atoms, maximal sharing, etc.
All the reading methods offer a version suffixed with _at(..., path: &Path)
,
which lets the writer determine what item we're reading in the AST. This
may be used both for debugging purposes and for encodings that depend
on the current position in the AST (e.g. entropy coding).
Associated Types
Loading content...Required methods
fn done(self) -> Result<Self::Data, TokenWriterError>
Finish writing, produce data.
fn enter_tagged_tuple_at(
&mut self,
_node: &dyn Node,
_tag: &InterfaceName,
_children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
&mut self,
_node: &dyn Node,
_tag: &InterfaceName,
_children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
Write a tagged tuple.
The number of items is specified by the grammar, so it MAY not be
recorded by the TokenWriter
.
By convention, a null tagged tuple is the special tagged tuple "null", with no children.
fn enter_list_at(
&mut self,
_len: usize,
_path: &Path
) -> Result<(), TokenWriterError>
&mut self,
_len: usize,
_path: &Path
) -> Result<(), TokenWriterError>
Write a list.
By opposition to a tuple, the number of items is variable and MUST
be somehow recorded by the TokenWriter
.
fn string_at(
&mut self,
value: Option<&SharedString>,
_path: &Path
) -> Result<(), TokenWriterError>
&mut self,
value: Option<&SharedString>,
_path: &Path
) -> Result<(), TokenWriterError>
Write a single UTF-8 string.
If specified, the string MUST be UTF-8.
fn string_enum_at(
&mut self,
value: &SharedString,
path: &Path
) -> Result<(), TokenWriterError>
&mut self,
value: &SharedString,
path: &Path
) -> Result<(), TokenWriterError>
Write a single UTF-8 value from a string enumeration.
The default implementation uses `self.string``, but some encodings may use the extra information e.g. to represent the enumeration by an index in the list of possible values, or to encode string enums as interfaces.
fn float_at(
&mut self,
value: Option<f64>,
_path: &Path
) -> Result<(), TokenWriterError>
&mut self,
value: Option<f64>,
_path: &Path
) -> Result<(), TokenWriterError>
Write a single number.
fn unsigned_long_at(
&mut self,
value: u32,
_path: &Path
) -> Result<(), TokenWriterError>
&mut self,
value: u32,
_path: &Path
) -> Result<(), TokenWriterError>
Write a single u32.
fn bool_at(
&mut self,
value: Option<bool>,
_path: &Path
) -> Result<(), TokenWriterError>
&mut self,
value: Option<bool>,
_path: &Path
) -> Result<(), TokenWriterError>
Write single bool.
fn offset_at(&mut self, _path: &Path) -> Result<(), TokenWriterError>
Write the number of bytes left in this tuple.
Provided methods
fn exit_tagged_tuple_at(
&mut self,
_node: &dyn Node,
_tag: &InterfaceName,
_children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
&mut self,
_node: &dyn Node,
_tag: &InterfaceName,
_children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
fn exit_list_at(&mut self, _path: &Path) -> Result<(), TokenWriterError>
fn property_key_at(
&mut self,
value: Option<&PropertyKey>,
path: &Path
) -> Result<(), TokenWriterError>
&mut self,
value: Option<&PropertyKey>,
path: &Path
) -> Result<(), TokenWriterError>
fn identifier_name_at(
&mut self,
value: Option<&IdentifierName>,
path: &Path
) -> Result<(), TokenWriterError>
&mut self,
value: Option<&IdentifierName>,
path: &Path
) -> Result<(), TokenWriterError>
fn enter_scoped_dictionary_at(
&mut self,
_name: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
&mut self,
_name: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
Signal that, from this point, writing is expected to use a specialized dictionary.
Use of the specialized dictionary will stop at exit_scoped_dictionary_at
.
This method is called during when visiting a node labelled ScopedDictionary
,
once the dictionary name has been decoded.
May be ignored by implementations of TokenWriter that do not support dictionary switching.
fn exit_scoped_dictionary_at(
&mut self,
_name: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
&mut self,
_name: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
Signal that, from this point, writing is expected to return to the previous specialized dictionary.
This method is called upon exiting a node labelled ScopedDictionary
.
May be ignored by implementations of TokenWriter that do not support dictionary switching.
Implementors
impl TokenWriter for TreeTokenWriter
[src]
type Data = Box<[u8]>
fn done(self) -> Result<Self::Data, TokenWriterError>
[src]
fn enter_tagged_tuple_at(
&mut self,
_node: &dyn Node,
tag: &InterfaceName,
_children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
_node: &dyn Node,
tag: &InterfaceName,
_children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
fn exit_tagged_tuple_at(
&mut self,
_node: &dyn Node,
_tag: &InterfaceName,
children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
_node: &dyn Node,
_tag: &InterfaceName,
children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
fn enter_list_at(
&mut self,
_len: usize,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
_len: usize,
_path: &Path
) -> Result<(), TokenWriterError>
fn exit_list_at(&mut self, _path: &Path) -> Result<(), TokenWriterError>
[src]
fn string_at(
&mut self,
value: Option<&SharedString>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&SharedString>,
_path: &Path
) -> Result<(), TokenWriterError>
fn string_enum_at(
&mut self,
value: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
fn float_at(
&mut self,
value: Option<f64>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<f64>,
_path: &Path
) -> Result<(), TokenWriterError>
fn unsigned_long_at(
&mut self,
value: u32,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: u32,
_path: &Path
) -> Result<(), TokenWriterError>
fn bool_at(
&mut self,
value: Option<bool>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<bool>,
_path: &Path
) -> Result<(), TokenWriterError>
fn offset_at(&mut self, _path: &Path) -> Result<(), TokenWriterError>
[src]
fn property_key_at(
&mut self,
value: Option<&PropertyKey>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&PropertyKey>,
_path: &Path
) -> Result<(), TokenWriterError>
fn identifier_name_at(
&mut self,
value: Option<&IdentifierName>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&IdentifierName>,
_path: &Path
) -> Result<(), TokenWriterError>
impl TokenWriter for DictionaryBuilder
[src]
type Data = [u8; 0]
fn done(self) -> Result<Self::Data, TokenWriterError>
[src]
fn bool_at(
&mut self,
value: Option<bool>,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<bool>,
path: &IOPath
) -> Result<(), TokenWriterError>
fn float_at(
&mut self,
value: Option<f64>,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<f64>,
path: &IOPath
) -> Result<(), TokenWriterError>
fn unsigned_long_at(
&mut self,
value: u32,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: u32,
path: &IOPath
) -> Result<(), TokenWriterError>
fn string_enum_at(
&mut self,
value: &SharedString,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: &SharedString,
path: &IOPath
) -> Result<(), TokenWriterError>
fn string_at(
&mut self,
value: Option<&SharedString>,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&SharedString>,
path: &IOPath
) -> Result<(), TokenWriterError>
fn property_key_at(
&mut self,
value: Option<&PropertyKey>,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&PropertyKey>,
path: &IOPath
) -> Result<(), TokenWriterError>
fn identifier_name_at(
&mut self,
value: Option<&IdentifierName>,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&IdentifierName>,
path: &IOPath
) -> Result<(), TokenWriterError>
fn enter_list_at(
&mut self,
len: usize,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
len: usize,
path: &IOPath
) -> Result<(), TokenWriterError>
fn enter_tagged_tuple_at(
&mut self,
_node: &dyn Node,
tag: &InterfaceName,
_children: &[&FieldName],
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
_node: &dyn Node,
tag: &InterfaceName,
_children: &[&FieldName],
path: &IOPath
) -> Result<(), TokenWriterError>
fn offset_at(&mut self, _path: &IOPath) -> Result<(), TokenWriterError>
[src]
fn enter_scoped_dictionary_at(
&mut self,
name: &SharedString,
_path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
name: &SharedString,
_path: &IOPath
) -> Result<(), TokenWriterError>
fn exit_scoped_dictionary_at(
&mut self,
name: &SharedString,
_path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
name: &SharedString,
_path: &IOPath
) -> Result<(), TokenWriterError>
impl TokenWriter for Encoder
[src]
type Data = Box<[u8]>
fn done(self) -> Result<Self::Data, TokenWriterError>
[src]
fn bool_at(
&mut self,
value: Option<bool>,
path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<bool>,
path: &Path
) -> Result<(), TokenWriterError>
fn string_enum_at(
&mut self,
value: &SharedString,
path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: &SharedString,
path: &Path
) -> Result<(), TokenWriterError>
fn enter_tagged_tuple_at(
&mut self,
_node: &dyn Node,
tag: &InterfaceName,
_children: &[&FieldName],
path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
_node: &dyn Node,
tag: &InterfaceName,
_children: &[&FieldName],
path: &Path
) -> Result<(), TokenWriterError>
fn float_at(
&mut self,
value: Option<f64>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<f64>,
_path: &Path
) -> Result<(), TokenWriterError>
fn unsigned_long_at(
&mut self,
value: u32,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: u32,
_path: &Path
) -> Result<(), TokenWriterError>
fn string_at(
&mut self,
value: Option<&SharedString>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&SharedString>,
_path: &Path
) -> Result<(), TokenWriterError>
fn identifier_name_at(
&mut self,
value: Option<&IdentifierName>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&IdentifierName>,
_path: &Path
) -> Result<(), TokenWriterError>
fn property_key_at(
&mut self,
value: Option<&PropertyKey>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&PropertyKey>,
_path: &Path
) -> Result<(), TokenWriterError>
fn enter_list_at(
&mut self,
len: usize,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
len: usize,
_path: &Path
) -> Result<(), TokenWriterError>
fn enter_scoped_dictionary_at(
&mut self,
name: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
name: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
fn exit_scoped_dictionary_at(
&mut self,
name: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
name: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
fn offset_at(&mut self, _path: &Path) -> Result<(), TokenWriterError>
[src]
impl<'a> TokenWriter for &'a mut DictionaryBuilder
[src]
type Data = [u8; 0]
fn done(self) -> Result<Self::Data, TokenWriterError>
[src]
fn bool_at(
&mut self,
value: Option<bool>,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<bool>,
path: &IOPath
) -> Result<(), TokenWriterError>
fn float_at(
&mut self,
value: Option<f64>,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<f64>,
path: &IOPath
) -> Result<(), TokenWriterError>
fn unsigned_long_at(
&mut self,
value: u32,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: u32,
path: &IOPath
) -> Result<(), TokenWriterError>
fn string_enum_at(
&mut self,
value: &SharedString,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: &SharedString,
path: &IOPath
) -> Result<(), TokenWriterError>
fn string_at(
&mut self,
value: Option<&SharedString>,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&SharedString>,
path: &IOPath
) -> Result<(), TokenWriterError>
fn property_key_at(
&mut self,
value: Option<&PropertyKey>,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&PropertyKey>,
path: &IOPath
) -> Result<(), TokenWriterError>
fn identifier_name_at(
&mut self,
value: Option<&IdentifierName>,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&IdentifierName>,
path: &IOPath
) -> Result<(), TokenWriterError>
fn enter_list_at(
&mut self,
len: usize,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
len: usize,
path: &IOPath
) -> Result<(), TokenWriterError>
fn enter_tagged_tuple_at(
&mut self,
node: &dyn Node,
tag: &InterfaceName,
children: &[&FieldName],
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
node: &dyn Node,
tag: &InterfaceName,
children: &[&FieldName],
path: &IOPath
) -> Result<(), TokenWriterError>
fn offset_at(&mut self, path: &IOPath) -> Result<(), TokenWriterError>
[src]
fn enter_scoped_dictionary_at(
&mut self,
name: &SharedString,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
name: &SharedString,
path: &IOPath
) -> Result<(), TokenWriterError>
fn exit_scoped_dictionary_at(
&mut self,
name: &SharedString,
path: &IOPath
) -> Result<(), TokenWriterError>
[src]
&mut self,
name: &SharedString,
path: &IOPath
) -> Result<(), TokenWriterError>
impl<T> TokenWriter for TokenWriterTreeAdapter<T> where
T: TokenWriterWithTree,
[src]
T: TokenWriterWithTree,
type Data = T::Data
fn done(self) -> Result<Self::Data, TokenWriterError>
[src]
fn enter_tagged_tuple_at(
&mut self,
_node: &dyn Node,
_tag: &InterfaceName,
_children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
_node: &dyn Node,
_tag: &InterfaceName,
_children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
fn exit_tagged_tuple_at(
&mut self,
_node: &dyn Node,
tag: &InterfaceName,
children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
_node: &dyn Node,
tag: &InterfaceName,
children: &[&FieldName],
_path: &Path
) -> Result<(), TokenWriterError>
fn enter_list_at(
&mut self,
_len: usize,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
_len: usize,
_path: &Path
) -> Result<(), TokenWriterError>
fn exit_list_at(&mut self, _path: &Path) -> Result<(), TokenWriterError>
[src]
fn string_at(
&mut self,
value: Option<&SharedString>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&SharedString>,
_path: &Path
) -> Result<(), TokenWriterError>
fn string_enum_at(
&mut self,
value: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: &SharedString,
_path: &Path
) -> Result<(), TokenWriterError>
fn float_at(
&mut self,
value: Option<f64>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<f64>,
_path: &Path
) -> Result<(), TokenWriterError>
fn unsigned_long_at(
&mut self,
value: u32,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: u32,
_path: &Path
) -> Result<(), TokenWriterError>
fn bool_at(
&mut self,
value: Option<bool>,
_path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<bool>,
_path: &Path
) -> Result<(), TokenWriterError>
fn offset_at(&mut self, _path: &Path) -> Result<(), TokenWriterError>
[src]
fn property_key_at(
&mut self,
value: Option<&PropertyKey>,
path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&PropertyKey>,
path: &Path
) -> Result<(), TokenWriterError>
fn identifier_name_at(
&mut self,
value: Option<&IdentifierName>,
path: &Path
) -> Result<(), TokenWriterError>
[src]
&mut self,
value: Option<&IdentifierName>,
path: &Path
) -> Result<(), TokenWriterError>