Crate flatdata[−][src]
Implementation of heremaps/flatdata in Rust.
Flatdata is a library providing data structures for convenient creation, storage and access of packed memory-mappable structures with minimal overhead.
The idea is, that the user defines a schema of the data format using flatdata's very simple schema language supporting plain structs, vectors and multivectors. The schema is then used to generate builders and readers for serialization and deserialization of the data. The data is serialized in a portable way which allows zero-overhead random access to it by using memory mapped storage. Memory mapped approach makes it possible to use the operating system facilities for loading, caching and paging of the data, and most important, accessing it as if it were in memory. Read more in "Why flatdata?".
This create provides:
- macros for generated code (prefixed with
create_
), - macros for zero-cost serialization
read_bytes
and deserializationwrite_bytes
, * in-memoryMemoryResourceStorage
and memory-mappedFileResourceStorage
storages, * data structures for writing data:StructBuf
,Vector
,ExternalVector
,MultiVector
, - data structures for reading data:
ArrayView
,MultiArrayView
.
The generator is part of the main heremaps/flatdata repository.
For a comprehensive example, cf. coappearances generated code and the corresponding usage.
Modules
helper |
Module containing helper traits and macros. |
Macros
define_archive |
Macro used by generator to define a flatdata archive and corresponding archive builder. |
define_index |
Macro used by generator to define a flatdata index. |
define_struct |
Macro used by generator to define a flatdata struct. |
define_variadic_struct |
Macro used by generator to define a flatdata variant used in |
read_bytes |
Reads specified number of bits from data at specified offset in portable way. |
write_bytes |
Writes specified number of bits of a given value to a slice at a specified offset in portable way. |
Structs
ArrayView |
A read-only view on a contiguous sequence of flatdata structs of the same
type |
ExternalVector |
Vector which flushes its content when growing. |
FileResourceStorage |
Resource storage on disk using memory mapped files. |
Handle |
Handle to a flatdata struct for read-only fields access. |
HandleMut |
Mutable handle to a flatdata struct for reading and writing fields. |
MemoryDescriptor |
Describes a chunk of memory |
MemoryResourceStorage |
Resource storage in memory. |
MultiArrayView |
A read-only view on a multivector. |
MultiVector |
A container for writing an indexed sequence of heterogeneous data items. |
StructBuf |
A container holding a single flatdata struct in memory, and providing read and write access to it. |
Vector |
A container holding a contiguous sequence of flatdata structs of the same
type |
Enums
ResourceStorageError |
Error indicating failures when reading and writing data from/to a
|
Traits
Archive |
A flatdata archive representing serialized data. |
ArchiveBuilder |
A flatdata archive builder for serializing data. |
Index |
A type in archive used as index of a |
IndexMut |
A type in archive used as mutable index of a |
ResourceStorage |
Hierarchical Resource Storage |
Struct |
A type in flatdata used for reading data. |
StructMut |
A mutable type in flatdata used for writing data. |
VariadicStruct |
A type used as element of |
Functions
create_archive |
Creates a new archive in resource storage. |
create_external_vector |
Helper for creating an external vector in the given resource storage. |
create_multi_vector |
Helper for creating a multivector in the given resource storage. |
Type Definitions
TypeIndex |
Index specifying a variadic type of |