pub struct TypeTree {
pub nodes: Vec<Node>,
/* private fields */
}Expand description
A class’s type tree; node 0 is the root.
Fields§
§nodes: Vec<Node>The nodes, the root first.
Implementations§
Source§impl TypeTree
impl TypeTree
Sourcepub fn new(nodes: Vec<Node>) -> Result<Self>
pub fn new(nodes: Vec<Node>) -> Result<Self>
Build a tree from its nodes (the root first). Refused: no nodes, a child index that is not after its parent’s
or not in the list, a pair without two children, or a vector whose Array child does not have two children.
Sourcepub fn root(&self) -> Option<&Node>
pub fn root(&self) -> Option<&Node>
The root node; None only when TypeTree::nodes was emptied after TypeTree::new refused an empty tree.
Sourcepub fn decode(&self, data: &[u8], big_endian: bool) -> Result<(Value, usize)>
pub fn decode(&self, data: &[u8], big_endian: bool) -> Result<(Value, usize)>
Decode data (an object’s bytes) from its start; returns the value and the bytes consumed.
Sourcepub fn decode_field(
&self,
data: &[u8],
big_endian: bool,
name: &str,
) -> Result<Option<Value>>
pub fn decode_field( &self, data: &[u8], big_endian: bool, name: &str, ) -> Result<Option<Value>>
The root struct’s field name alone: the fields before it are walked (and so must decode), the ones after it
are not read, so a name stored first costs a few bytes whatever the object holds. None when the root has no
such field; the value is what TypeTree::decode gives it. A root that is not a struct has no fields.