[−][src]Trait binjs::io::TokenWriterWithTree
Associated Types
type Tree
type Data: AsRef<[u8]>
The type of data generated by this writer.
Typically some variant of Vec<u8>
.
Required methods
fn done(self) -> Result<Self::Data, TokenWriterError>
Finish writing, produce data.
fn tagged_tuple(
&mut self,
_tag: &InterfaceName,
_children: &[(&FieldName, Self::Tree)]
) -> Result<Self::Tree, TokenWriterError>
&mut self,
_tag: &InterfaceName,
_children: &[(&FieldName, Self::Tree)]
) -> Result<Self::Tree, 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 list(&mut self, Vec<Self::Tree>) -> Result<Self::Tree, TokenWriterError>
Write a list.
By opposition to a tuple, the number of items is variable and MUST
be somehow recorded by the TokenWriter
.
Provided methods
fn string(
&mut self,
Option<&SharedString>
) -> Result<Self::Tree, TokenWriterError>
&mut self,
Option<&SharedString>
) -> Result<Self::Tree, TokenWriterError>
Write a single UTF-8 string.
If specified, the string MUST be UTF-8.
fn string_enum(
&mut self,
str: &SharedString
) -> Result<Self::Tree, TokenWriterError>
&mut self,
str: &SharedString
) -> Result<Self::Tree, 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(&mut self, Option<f64>) -> Result<Self::Tree, TokenWriterError>
Write a single number.
fn unsigned_long(&mut self, u32) -> Result<Self::Tree, TokenWriterError>
Write a single u32.
fn bool(&mut self, Option<bool>) -> Result<Self::Tree, TokenWriterError>
Write single bool.
fn offset(&mut self) -> Result<Self::Tree, TokenWriterError>
Write the number of bytes left in this tuple.
fn property_key(
&mut self,
value: Option<&PropertyKey>
) -> Result<Self::Tree, TokenWriterError>
&mut self,
value: Option<&PropertyKey>
) -> Result<Self::Tree, TokenWriterError>
fn identifier_name(
&mut self,
value: Option<&IdentifierName>
) -> Result<Self::Tree, TokenWriterError>
&mut self,
value: Option<&IdentifierName>
) -> Result<Self::Tree, TokenWriterError>
Implementors
impl TokenWriterWithTree for binjs::io::multipart::TreeTokenWriter
[src]
type Tree = Tree
type Data = Box<[u8]>
fn done(
self
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Data, TokenWriterError>
[src]
self
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Data, TokenWriterError>
fn float(
&mut self,
value: Option<f64>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
value: Option<f64>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn unsigned_long(
&mut self,
value: u32
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
value: u32
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn bool(
&mut self,
data: Option<bool>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
data: Option<bool>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn offset(
&mut self
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn string(
&mut self,
data: Option<&SharedString>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
data: Option<&SharedString>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn list(
&mut self,
children: Vec<<TreeTokenWriter as TokenWriterWithTree>::Tree>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
children: Vec<<TreeTokenWriter as TokenWriterWithTree>::Tree>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn tagged_tuple(
&mut self,
name: &InterfaceName,
children: &[(&FieldName, <TreeTokenWriter as TokenWriterWithTree>::Tree)]
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
name: &InterfaceName,
children: &[(&FieldName, <TreeTokenWriter as TokenWriterWithTree>::Tree)]
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
impl TokenWriterWithTree for binjs::io::simple::TreeTokenWriter
[src]
type Tree = AbstractTree
type Data = Box<[u8]>
fn done(
self
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Data, TokenWriterError>
[src]
self
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Data, TokenWriterError>
fn float(
&mut self,
data: Option<f64>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
data: Option<f64>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn bool(
&mut self,
data: Option<bool>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
data: Option<bool>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn offset(
&mut self
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn unsigned_long(
&mut self,
data: u32
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
data: u32
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn string(
&mut self,
data: Option<&SharedString>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
data: Option<&SharedString>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
fn list(
&mut self,
items: Vec<<TreeTokenWriter as TokenWriterWithTree>::Tree>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
items: Vec<<TreeTokenWriter as TokenWriterWithTree>::Tree>
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
Lists are represented as:
- "
- "
- number of items (u32);
- items
- ""
The number of bytes is the total size of
- number of items;
- items.
fn tagged_tuple(
&mut self,
tag: &InterfaceName,
children: &[(&FieldName, <TreeTokenWriter as TokenWriterWithTree>::Tree)]
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
tag: &InterfaceName,
children: &[(&FieldName, <TreeTokenWriter as TokenWriterWithTree>::Tree)]
) -> Result<<TreeTokenWriter as TokenWriterWithTree>::Tree, TokenWriterError>
For this example, we use a very, very, very suboptimal encoding.
- - kind (string, \0 terminated) - number of items (varnum) - field names (string, \0 terminated)
- contents
impl TokenWriterWithTree for Encoder
[src]
type Tree = Rc<SubTree>
type Data = Box<[u8]>
fn bool(
&mut self,
data: Option<bool>
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
data: Option<bool>
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
fn unsigned_long(
&mut self,
data: u32
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
data: u32
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
fn float(
&mut self,
data: Option<f64>
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
data: Option<f64>
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
fn string(
&mut self,
data: Option<&SharedString>
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
data: Option<&SharedString>
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
fn tagged_tuple(
&mut self,
tag: &InterfaceName,
items: &[(&FieldName, <Encoder as TokenWriterWithTree>::Tree)]
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
tag: &InterfaceName,
items: &[(&FieldName, <Encoder as TokenWriterWithTree>::Tree)]
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
fn list(
&mut self,
items: Vec<<Encoder as TokenWriterWithTree>::Tree>
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self,
items: Vec<<Encoder as TokenWriterWithTree>::Tree>
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
fn offset(
&mut self
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
[src]
&mut self
) -> Result<<Encoder as TokenWriterWithTree>::Tree, TokenWriterError>
fn done(
self
) -> Result<<Encoder as TokenWriterWithTree>::Data, TokenWriterError>
[src]
self
) -> Result<<Encoder as TokenWriterWithTree>::Data, TokenWriterError>