Module visitor

Module visitor 

Source
Expand description

Visitor is a tree-based serializer/deserializer.

§Overview

Visitor uses tree to create structured storage of data. Basic unit is a node - it is a container for data fields. Each node has name, handle to parent, set of handles to children nodes and some container for data fields. Data field is tuple of name and value, value can be any of simple Rust types and some of basic structures of the crate. Main criteria of what could be the field and what not is the ability to be represented as set of bytes without any aliasing issues.

Modules§

prelude
Types to use #[derive(Visit)]

Structs§

BinaryBlob
Proxy struct for plain data, we can’t use Vec<u8> directly, because it will serialize each byte as separate node. BinaryBlob stores data very much like PodVecView except that BinaryBlob has less type safety. In practice it is used with T = u8 for Strings and Paths, but it accepts any type T that is Copy, and it lacks the type_id system that PodVecView has for checking that the data it is reading comes from the expected type.
Blackboard
A Blackboard is a mapping from TypeId to value that allows a Visitor to store a particular value for each registered type.
Field
Values within a visitor are constructed from Fields. Each Field has a name and a value. The name is used as a key to access the value within the visitor using the Visit::visit method, so each field within a value must have a unique name.
PodVecView
A Visit type for storing a whole Vec of Pod values as a single field within a Visitor. The Vec is reinterpreted as a Vec of bytes, with no consideration given for whether the bytes are in big-endian or little-endian order by using std::ptr::copy_nonoverlapping.
RegionGuard
A RegionGuard is a Visitor that automatically leaves the current region when it is dropped.
Visitor
A collection of nodes that stores data that can be read or write values of types with the Visit trait.
VisitorFlags
Flags that can be used to influence the behaviour of Visit::visit methods.
VisitorNode
A node is a collection of Fields that exists within a tree of nodes that allows a Visitor to store its data. Each node has a name, and may have a parent node and child nodes.

Enums§

FieldKind
The internal data format of Visitor. Fields are limited to being one of these types. This means that all Visit values must be built from some assortment of these types. Fields can be accessed from a visitor using Visit::visit on a variable with the same type as the field.
VisitError
Errors that may occur while reading or writing Visitor.

Traits§

Pod
Trait for datatypes that can be converted directly into bytes. This is required for the type to be used in the Vec of a PodVecView.
Visit
Trait of types that can be read from a Visitor or written to a Visitor.

Type Aliases§

VisitResult
The result of a Visit::visit or of a Visitor encoding operation such as Visitor::save_binary. It has no value unless an error occurred.

Derive Macros§

Visit
Implements Visit trait