Skip to content

Repository files navigation

ObjectBox Code Generator

GitHub snapshot (not a live mirror).
The canonical repository is on GitLab:
https://gitlab.com/Obsidian_Jackal/objectbox-generator-rs

This GitHub copy is a manual upload: it does not include the full git history from GitLab, and it is not updated automatically. Prefer GitLab for clones, issues, and merge requests. Refresh this GitHub tree by hand when you want a newer snapshot.

Rust code generator for ObjectBox FlatBuffer schemas. Generates type-safe Rust code with FlatBuffer encoding/decoding from .fbs schema files.

Features

  • ✅ Parses .fbs schema files
  • ✅ Generates Rust structs with proper types
  • ✅ Generates FlatBuffer encoding (to_flatbuffer())
  • ✅ Generates FlatBuffer decoding (from_flatbuffer())
  • ✅ Supports: Long, Int, String, ByteVector, Bool, Float, Double
  • ✅ ObjectBox-compatible format

Usage

As a Library

use objectbox_codegen::{parse_schema_file, generate_rust_code};

// Parse schema
let schema = parse_schema_file("schemas/my_entity.fbs")?;

// Generate Rust code
generate_rust_code(&schema, "generated/")?;

Example

cargo run --example test_codegen

Schema Format

table KeyValue {
    id: ulong;      // ObjectBox ID
    value: [byte];  // ByteVector to store data
}

Generated Code

The generator creates:

  • Rust structs matching the schema
  • to_flatbuffer() method for encoding
  • from_flatbuffer() method for decoding
  • Proper type conversions
  • ObjectBox-compatible FlatBuffer format

Dependencies

  • anyhow - Error handling

License

AGPL-3.0 (GNU Affero General Public License v3)

This project is licensed under AGPL-3.0 to respect the license of the original ObjectBox Generator (also AGPL-3.0) and ensure legal compliance.

Important: The generated code (output) is yours to license as you wish. You can regard generated code as your own code with no license restrictions.

See LICENSE for full license text.

Why AGPL-3.0?

This code generator was created by reverse-engineering the approach and output format of the official ObjectBox Generator. While no source code was copied, and the implementation was written from scratch in Rust, we've chosen AGPL-3.0 to:

  • Respect ObjectBox Generator's license
  • Ensure legal compliance
  • Contribute to open source

See DEVELOPMENT.md for details on how this was created.

Repository

About

Generate ObjectBox-compatible Rust entity code from FlatBuffer .fbs schemas. (GitLab mirror)

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages