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
- BackwardsS
Offset - ForwardsSOffset is used by Follow to traverse a FlatBuffer: the pointer is incremented by the negative of the value contained in this type.
- Default
Allocator - Default
FlatBufferBuilder
allocator backed by aVec<u8>
. - File
Identifier - FileIdentifier is used by Follow to traverse a FlatBuffer: the pointer is dereferenced into a byte slice, whose bytes are the file identifer value.
- Flat
Buffer Builder - FlatBufferBuilder builds a FlatBuffer through manipulating its internal
state. It has an owned
Vec<u8>
that grows as needed (up to the hardcoded limit of 2GiB, which is set by the FlatBuffers format). - Follow
Start - FollowStart wraps a Follow impl in a struct type. This can make certain programming patterns more ergonomic.
- ForwardsU
Offset - ForwardsUOffset is used by Follow to traverse a FlatBuffer: the pointer is incremented by the value contained in this type.
- ForwardsV
Offset - ForwardsVOffset is used by Follow to traverse a FlatBuffer: the pointer is incremented by the value contained in this type.
- Push
Alignment - Ensure Push alignment calculations are typesafe (because this helps reduce implementation issues when using FlatBufferBuilder::align).
- Skip
File Identifier - 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.
- Skip
Root Offset - 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.
- Skip
Size Prefix - 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
- Table
FinishedWIP Offset - TableFinishedWIPOffset marks a WIPOffset as being for a finished table.
- Table
UnfinishedWIP Offset - TableUnfinishedWIPOffset marks a WIPOffset as being for an unfinished table.
- Table
Verifier - UnionWIP
Offset - UnionWIPOffset marks a WIPOffset as being for a union value.
- VTableWIP
Offset - VTableWIPOffset marks a WIPOffset as being for a vtable.
- Vector
- Vector
Iter - An iterator over a
Vector
. - Verifier
- Carries the verification state. Should not be reused between tables.
- Verifier
Options - 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§
- Error
Trace Detail - 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.
- Invalid
Flatbuffer - 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§
- FILE_
IDENTIFIER_ LENGTH - FLATBUFFERS_
MAX_ BUFFER_ SIZE - SIZE_
F32 - SIZE_
F64 - SIZE_I8
- SIZE_
I16 - SIZE_
I32 - SIZE_
I64 - SIZE_
SIZEPREFIX - SIZE_
SOFFSET - SIZE_U8
- SIZE_
U16 - SIZE_
U32 - SIZE_
U64 - SIZE_
UOFFSET - SIZE_
VOFFSET - VTABLE_
METADATA_ FIELDS
Traits§
- Allocator
- Trait to implement custom allocation strategies for
FlatBufferBuilder
. - Endian
Scalar - 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.
- Simple
ToVerify InSlice - Verifiable
Functions§
- array_
init - buffer_
has_ identifier - Returns true if data contains a prefix of
ident
- emplace_
scalar ⚠ - Place an EndianScalar into the provided mutable byte slice. Performs endian conversion, if necessary.
- emplace_
scalar_ ⚠array - Place an array of EndianScalar into the provided mutable byte slice. Performs endian conversion, if necessary.
- field_
index_ to_ field_ offset - follow_
cast_ ⚠ref - Safety
- 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
_unchecked
variants for previous behavior. - 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
_unchecked
variants for previous behavior. - 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
_unchecked
variants for previous behavior. - 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
_unchecked
variants for previous behavior.