foxglove-flatbuffers 0.3.7

Rust bindings for Foxglove FlatBuffer message schemas
docs.rs failed to build foxglove-flatbuffers-0.3.7
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: foxglove-flatbuffers-0.3.6

Foxglove FlatBuffers

Crates.io Documentation

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:

[dependencies]
foxglove-flatbuffers = { version = "0.1", features = ["no_std"] }

Limitations:

  • ✅ Reading FlatBuffer messages works in no_std + alloc environments
  • ⚠️ Requires alloc (heap allocation) - pure no_std without alloc is not supported
  • ⚠️ Writing FlatBuffer messages (using FlatBufferBuilder) may have limitations in no_std environments
  • ⚠️ Some flatbuffers builder APIs may require std features

Pre-generated Code:

The code is already pre-generated and included in the repository. This means:

  • ✅ No flatc compiler needed for normal usage
  • ✅ Faster builds (no code generation step)
  • ✅ Works in no_std environments with alloc

If you're a maintainer and need to regenerate the code (e.g., after schema updates):

./scripts/download_schemas.sh  # Download latest schemas
./scripts/generate_and_commit.sh  # Regenerate and commit code

Installation

Add this to your Cargo.toml:

[dependencies]
foxglove-flatbuffers = "0.1"
flatbuffers = "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

brew install flatbuffers

Linux (Ubuntu/Debian)

sudo apt-get install flatbuffers-compiler

Other Platforms

Download from: https://github.com/google/flatbuffers/releases

Usage

Reading FlatBuffer Messages

use foxglove_flatbuffers::*;
use flatbuffers::GetRoot;

// Your FlatBuffer bytes
let data: &[u8] = /* ... */;

// 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 foxglove_flatbuffers::*;
use flatbuffers::{FlatBufferBuilder, WIPOffset};

// Create a builder
let mut builder = FlatBufferBuilder::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

  1. Clone the repository
  2. Build the crate (no flatc needed - uses pre-generated code):
    cargo build
    

For maintainers: If you need to regenerate the code:

  1. Install flatc (see Prerequisites above)
  2. Download schemas:
    ./scripts/download_schemas.sh
    
  3. Regenerate code:
    ./scripts/generate_and_commit.sh
    

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, Duration
  • Pose, PoseInFrame, PosesInFrame
  • Point2, Point3, Vector2, Vector3
  • Quaternion
  • SceneUpdate, SceneEntity
  • PointCloud, LaserScan
  • CompressedImage, RawImage
  • CameraCalibration
  • LocationFix, 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