Foxglove FlatBuffers
Rust bindings for Foxglove FlatBuffer message schemas.
This crate provides type-safe Rust bindings for all Foxglove FlatBuffer message types, generated from the official Foxglove schemas.
Features
- Type-safe Rust bindings for all Foxglove FlatBuffer message types
- Zero-copy deserialization using FlatBuffers
- Support for reading and writing Foxglove-compatible messages
- Auto-generated from official Foxglove schemas
- No runtime dependencies beyond
flatbuffers
no_std Support
This crate supports no_std environments with alloc when using pre-generated code!
The pre-generated feature is enabled by default. For no_std support, enable the no_std feature:
[]
= { = "0.1", = ["no_std"] }
Limitations:
- ✅ Reading FlatBuffer messages works in
no_std+allocenvironments - ⚠️ Requires
alloc(heap allocation) - pureno_stdwithoutallocis not supported - ⚠️ Writing FlatBuffer messages (using
FlatBufferBuilder) may have limitations inno_stdenvironments - ⚠️ Some
flatbuffersbuilder APIs may requirestdfeatures
Pre-generated Code:
The code is already pre-generated and included in the repository. This means:
- ✅ No
flatccompiler needed for normal usage - ✅ Faster builds (no code generation step)
- ✅ Works in
no_stdenvironments withalloc
If you're a maintainer and need to regenerate the code (e.g., after schema updates):
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= "24.3"
Note: By default, this crate uses pre-generated code, so you don't need the FlatBuffers compiler (flatc) installed. The code is already included in the repository.
Prerequisites
No prerequisites required by default! The crate uses pre-generated code that's included in the repository.
If you want to generate code at build time instead (by disabling the default pre-generated feature), you'll need the FlatBuffers compiler (flatc):
macOS
Linux (Ubuntu/Debian)
Other Platforms
Download from: https://github.com/google/flatbuffers/releases
Usage
Reading FlatBuffer Messages
use *;
use GetRoot;
// Your FlatBuffer bytes
let data: & = /* ... */;
// Read a Time message (example)
// Note: Actual API depends on generated code structure
// let time = Time::get_root_as_root(data);
Writing FlatBuffer Messages
use *;
use ;
// Create a builder
let mut builder = new;
// Build your message using the generated types
// (Example - actual API depends on generated code)
// let time_offset = Time::create(&mut builder, &time_args);
// Finish the buffer
// builder.finish(time_offset, None);
// let finished_data = builder.finished_data();
Development
Setting Up
- Clone the repository
- Build the crate (no
flatcneeded - uses pre-generated code):
For maintainers: If you need to regenerate the code:
- Install
flatc(see Prerequisites above) - Download schemas:
- Regenerate code:
Project Structure
foxglove-flatbuffers/
├── Cargo.toml # Crate configuration
├── build.rs # Build script for code generation (when pre-generated disabled)
├── schemas/ # FlatBuffer schema files (.fbs) - optional, for regeneration
├── scripts/
│ ├── download_schemas.sh # Script to download schemas
│ └── generate_and_commit.sh # Script to regenerate code
└── src/
├── lib.rs # Library entry point
└── generated/ # Pre-generated Rust code (included in repo)
└── foxglove/ # Generated message types
Supported Message Types
This crate supports all Foxglove FlatBuffer message types, including:
Time,DurationPose,PoseInFrame,PosesInFramePoint2,Point3,Vector2,Vector3QuaternionSceneUpdate,SceneEntityPointCloud,LaserScanCompressedImage,RawImageCameraCalibrationLocationFix,GeoJSON- And many more...
See the Foxglove schemas repository for the complete list.
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Related Projects
- Foxglove Studio - Robotics visualization platform
- Foxglove Schemas - Message schema definitions
- FlatBuffers - Efficient cross-platform serialization library