Crate flatbuffers[−][src]
Expand description
FlatBuffers
A library for memory-efficient serialization of data.
This crate provides runtime support for the FlatBuffers format in the Rust programming language.
To use this crate, first generate code with the flatc
compiler, as described here: https://google.github.io/flatbuffers/
Then, include that code into your project.
Finally, add this crate to your Cargo.toml
.
At this time, Rust support is experimental, and APIs may change between minor versions.
At this time, to generate Rust code, you will need the latest master
version of flatc
, available from here: https://github.com/google/flatbuffers
(On OSX, you can install FlatBuffers from HEAD
with the Homebrew package manager.)
Re-exports
pub use bitflags; |
Structs
Array | |
BackwardsSOffset | ForwardsSOffset is used by Follow to traverse a FlatBuffer: the pointer is incremented by the negative of the value contained in this type. |
FileIdentifier | FileIdentifier is used by Follow to traverse a FlatBuffer: the pointer is dereferenced into a byte slice, whose bytes are the file identifer value. |
FlatBufferBuilder | FlatBufferBuilder builds a FlatBuffer through manipulating its internal
state. It has an owned |
FollowStart | FollowStart wraps a Follow impl in a struct type. This can make certain programming patterns more ergonomic. |
ForwardsUOffset | ForwardsUOffset is used by Follow to traverse a FlatBuffer: the pointer is incremented by the value contained in this type. |
ForwardsVOffset | ForwardsVOffset is used by Follow to traverse a FlatBuffer: the pointer is incremented by the value contained in this type. |
SkipFileIdentifier | SkipFileIdentifier is used by Follow to traverse a FlatBuffer: the pointer is incremented by a fixed constant in order to skip over the file identifier value. |
SkipRootOffset | SkipRootOffset is used by Follow to traverse a FlatBuffer: the pointer is incremented by a fixed constant in order to skip over the root offset value. |
SkipSizePrefix | SkipSizePrefix is used by Follow to traverse a FlatBuffer: the pointer is incremented by a fixed constant in order to skip over the size prefix value. |
Table | |
TableFinishedWIPOffset | TableFinishedWIPOffset marks a WIPOffset as being for a finished table. |
TableUnfinishedWIPOffset | TableUnfinishedWIPOffset marks a WIPOffset as being for an unfinished table. |
UnionWIPOffset | UnionWIPOffset marks a WIPOffset as being for a union value. |
VTableWIPOffset | VTableWIPOffset marks a WIPOffset as being for a vtable. |
Vector | |
VectorIter | An iterator over a |
Verifier | Carries the verification state. Should not be reused between tables. |
VerifierOptions | |
WIPOffset | WIPOffset contains an UOffsetT with a special meaning: it is the location of data relative to the end of an in-progress FlatBuffer. The FlatBufferBuilder uses this to track the location of objects in an absolute way. The impl of Push converts a WIPOffset into a ForwardsUOffset. |
Enums
ErrorTraceDetail | Traces the location of data errors. Not populated for Dos detecting errors. Useful for MissingRequiredField and Utf8Error in particular, though the other errors should not be producible by correct flatbuffers implementations. |
InvalidFlatbuffer | Describes how a flatuffer is invalid and, for data errors, roughly where. No extra tracing information is given for DoS detecting errors since it will probably be a lot. |
Constants
Traits
EndianScalar | Trait for values that must be stored in little-endian byte order, but might be represented in memory as big-endian. Every type that implements EndianScalar is a valid FlatBuffers scalar value. |
Follow | Follow is a trait that allows us to access FlatBuffers in a declarative, type safe, and fast way. They compile down to almost no code (after optimizations). Conceptually, Follow lifts the offset-based access patterns of FlatBuffers data into the type system. This trait is used pervasively at read time, to access tables, vtables, vectors, strings, and all other data. At this time, Follow is not utilized much on the write path. |
Push | Trait to abstract over functionality needed to write values (either owned or referenced). Used in FlatBufferBuilder and implemented for generated types. |
SafeSliceAccess | |
SimpleToVerifyInSlice | |
Verifiable |
Functions
array_init | |
buffer_has_identifier | |
byte_swap_f32 | Swaps the bytes of an f32. |
byte_swap_f64 | Swaps the bytes of an f64. |
emplace_scalar⚠ | Place an EndianScalar into the provided mutable byte slice. Performs endian conversion, if necessary. |
emplace_scalar_array | |
field_index_to_field_offset | |
follow_cast_ref | |
read_scalar⚠ | Read an EndianScalar from the provided byte slice. Performs endian conversion, if necessary. |
read_scalar_at⚠ | Read an EndianScalar from the provided byte slice at the specified location. Performs endian conversion, if necessary. |
root | Gets the root of the Flatbuffer, verifying it first with default options.
Note that verification is an experimental feature and may not be maximally performant or
catch every error (though that is the goal). See the |
root_unchecked⚠ | Gets root for a trusted Flatbuffer. |
root_with_opts | Gets the root of the Flatbuffer, verifying it first with given options.
Note that verification is an experimental feature and may not be maximally performant or
catch every error (though that is the goal). See the |
size_prefixed_root | Gets the root of a size prefixed Flatbuffer, verifying it first with default options.
Note that verification is an experimental feature and may not be maximally performant or
catch every error (though that is the goal). See the |
size_prefixed_root_unchecked⚠ | Gets root for a trusted, size prefixed, Flatbuffer. |
size_prefixed_root_with_opts | Gets the root of a size prefixed Flatbuffer, verifying it first with given options.
Note that verification is an experimental feature and may not be maximally performant or
catch every error (though that is the goal). See the |
Type Definitions
SOffsetT | SOffsetT is a relative pointer from tables to their vtables. |
UOffsetT | UOffsetT is used represent both for relative pointers and lengths of vectors. |
VOffsetT | VOffsetT is a relative pointer in vtables to point from tables to field data. |