FlatBuffers compiler (flatc) as API (with focus on transparent `.fbs` to `.rs` code-generation via Cargo build scripts integration)

Overview

FlatBuffers flatc API for Rust crates.io Documentation Build Status

This crate provides a programmatical way to invoke flatc command (e.g. from build.rs) to generate Rust (or, in fact, any other language) helpers to work with FlatBuffers.

NOTE: You will still need flatc utility version 1.10.0+ installed (there are windows binary releases, flatbuffers packages for conda [Windows, Linux, MacOS], Arch Linux).

Usage and Examples

Please, refer to the documentation for usage instructions and examples.

Acknowledgements

The design of the API was inspired by protoc-rust, protoc, and capnpc.

License

This project is licensed under either of

at your option.

Comments
  • Error while compiling the generated code: the trait Default is not implemented for [u8; 40]

    Error while compiling the generated code: the trait Default is not implemented for [u8; 40]

    error[E0277]: the trait bound `[u8; 40]: Default` is not satisfied
       --> cluster/protofiles/src/struct_generated.rs:707:23
        |
    707 | pub struct COrderLink(pub [u8; 40]);
        |                       ^^^^^^^^^^^^ the trait `Default` is not implemented for `[u8; 40]`
        |
        = help: the following implementations were found:
                  <&[T] as Default>
                  <&mut [T] as Default>
                  <[T; 0] as Default>
                  <[T; 10] as Default>
                and 31 others
        = note: required by `std::default::Default::default`
        = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
    
    opened by XX 4
  •  Support AsRef instead of &Path for path parameters

    Support AsRef instead of &Path for path parameters

    Would it be possible to change the definition of the Args struct from &'a [&'a Path] to something like &'a [P] where P: AsRef<Path>?

    I have a Vec<PathBuf> that comes from reading a config file. I would like to be able to just pass it to flatc as Args{ inputs: &inputs[..], ... }.

    Thanks :)

    opened by rope-hmg 3
  • Add support to pass extra arguments to flatc

    Add support to pass extra arguments to flatc

    Added the ability to pass a list of arbitrary arguments to flatc so that we can use arguments other than the ones supported by the current Args struct. While it might be good to extend the Args struct to include more of the supported flatc args, I think it's still important to support any argument the user wants.

    Solves issues #9

    Update Flatc::from_path to take &Path instead of PathBuf. Taking a PathBuf forces from_path to take ownership of the passed inPathBuf which forces the user to clone it if they want to use it again. Taking a &Path doesn't take ownership but still clones it internally.

    opened by rminderhoud 2
  • Is it possible to pass all set of flatc args?

    Is it possible to pass all set of flatc args?

    flatc has rich set of arguments https://google.github.io/flatbuffers/flatbuffers_guide_using_schema_compiler.html

    I saw you implement the basic set that works just fine, but for example I'd love to modify the --filename-suffix, but cannot findout how?

    Help would be much appreciated!

    help wanted good first issue 
    opened by moiseevigor 2
  • Add flags appropriate for generating reflection

    Add flags appropriate for generating reflection

    I had a need to do some dynamic reflection of flatbuffers in rust, since the flatc rust generator doesn't out-of-the-box support --reflect-XXX flags.

    This just adds the binary, schema and json command line to the config for generating the binary representations for use with reflection.fbs

    opened by jaynus 2
  • New release?

    New release?

    Would it be possible to get a new release published? It would be useful to have this fix available in a published crate: https://github.com/frol/flatc-rust/pull/7

    (We get bitten by build breakages that require us to hand-edit our Cargo.lock every time we do a package upgrade)

    opened by maxburke 1
  • Fix includes

    Fix includes

    include paths currently do not work, as they are specified at the wrong position in the command and also write out the include path incorrect.

    flatc <options> <files> requires -I to move before inputs. Additionally, include paths are specified as -I <path> not -I<path>

    opened by jaynus 0
  • Improve ergonomics when dealing with `glob`s.

    Improve ergonomics when dealing with `glob`s.

    Would it be possible to change flatc_rust::Args.inputs to accept things of type AsRef<Path> instead of regular Path? That way it could accept PathBufs as well, which would make it easier to get it to interact with the glob crate.

    Would it be easy enough that a intermediate Rustacean might be able to send you a PR?

    opened by dunmatt 3
Owner
Vlad Frolov
:wq
Vlad Frolov
Diagrams as code

diagwiz -- ASCII diagrams as code Warning: This project is in early experimental stage. Functionality is subject to change and YMMV. Feel free to open

Krzysztof Jagiełło 41 Sep 16, 2022
A cargo subcommand that extends cargo's capabilities when it comes to code generation.

cargo-px Cargo Power eXtensions Check out the announcement post to learn more about cargo-px and the problems it solves with respect to code generatio

Luca Palmieri 33 May 7, 2023
A cargo subcommand to fetch the $OUT_DIR environment variable from build scripts

cargo-outdir A cargo subcommand to fetch the $OUT_DIR variable from build scripts. This is extremely useful to inspect the output of automatically gen

null 2 Sep 29, 2022
A performant binary encoding for geographic data based on flatbuffers

FlatGeobuf A performant binary encoding for geographic data based on flatbuffers that can hold a collection of Simple Features including circular inte

FlatGeobuf 477 Jan 5, 2023
cargo extension for flashing embedded rust programs via dfu based on jacobrosenthals cargo-hf2

cargo-dfu This crate provides a cargo subcommand to flash ELF binaries via dfu Most STM chips will probably work with this, although you might need to

Roman Kretschmer 0 Feb 6, 2022
Rust library for build scripts to compile C/C++ code into a Rust library

A library to compile C/C++/assembly into a Rust library/application.

Alex Crichton 1.3k Dec 21, 2022
Integra8 rust integration test framework Rust with a focus on productivity, extensibility, and speed.

integra8 Integra8 rust integration test framework Rust with a focus on productivity, extensibility, and speed. | This repo is in a "work in progress"

exceptional 3 Sep 26, 2022
Easy per application transparent proxy built on cgroup.

cproxy can redirect TCP and UDP traffic made by a program to a proxy, without requiring the program supporting a proxy. Compared to many existi

Xiangru Lian 263 Dec 20, 2022
A transparent QUIC to SOCKSv5 proxy on Linux, UDP/QUIC verison of moproxy.

quproxy A transparent QUIC to SOCKSv5 proxy on Linux, UDP/QUIC verison of moproxy. ?? WORKING IN PROGRESS ?? Features: Transparent forward QUIC to ups

Shell Chen 4 Dec 15, 2022
Test Electronic Control Units around the world in a transparent network.

Eclipse openDuT Test Electronic Control Units around the world in a transparent network. Eclipse openDuT provides an open framework to automate the te

Eclipse openDuT 6 Dec 22, 2023
Let Tauri's transparent background rendering window be stacked on Bevy's rendering window in real time to run the game with native-level performance!

Native Bevy with Tauri HUD DEMO 将 Tauri 的透明背景渲染窗口实时叠在 Bevy 的渲染窗口上,以使用原生级别性能运行游戏! Let Tauri's transparent background rendering window be stacked on Bev

伊欧 3 Mar 25, 2024
A CLI tool for CIs and build scripts, making file system based caching easy and correct (locking, eviction, etc.)

FS Dir Cache A CLI tool for CIs and build scripts, making file system based caching easy and correct (locking, eviction, etc.) When working on build s

Dawid Ciężarkiewicz 5 Aug 29, 2023
🔔 CLI utility to send notifications to Slack via integration webhooks

Slack notifier Just a simple CLI tool to send notifications to Slack. Please note that this project is just a playground to start learning Rust, it is

Green.Mod 2 May 21, 2022
Cargo-eval - A cargo plugin to quickly evaluate some Rust source code.

cargo eval A cargo plugin to quickly evaluate some Rust source code. Installation $ cargo install --git https://github.com/timClicks/cargo-eval.git Us

Tim McNamara 9 Dec 21, 2022
cargo-crev to cargo-vet code review exporter

cargo-crev to cargo-vet converter Crev and Vet are supply-chain security tools for auditing Rust/Cargo dependencies. This tool (crevette) is a helper

crev - Code REView system 3 Dec 6, 2023
Release complex cargo-workspaces automatically with changelog generation, used by `gitoxide`

cargo smart-release Fearlessly release workspace crates and with beautiful semi-handcrafted changelogs. Key Features zero-configuration cargo smart-re

Sebastian Thiel 24 Oct 11, 2023
Generate QR code easily for free - QR Code Generation as a Service.

QRcode.show Generate QR code easily for free - QR Code Generation as a Service. INPUT: curl qrcode.show/INPUT curl qrcode.show -d INPUT curl qrcode.sh

Arijit Basu 572 Dec 24, 2022
Extract data from helium-programs via Solana RPC and serves it via HTTP

hnt-explorer This application extracts data from helium-programs via Solana RPC and serves it via HTTP. There are CLI commands meant to run and test t

Louis Thiery 3 May 4, 2023
CYFS:Next Generation Protocol Family to Build Web3

CYFS is the next-generation technology to build real Web3 by upgrading the basic protocol of Web (TCP/IP+DNS+HTTP). It has a subversive architectural design that everyone brings their own OOD (Owner Online Device) to form a truly decentralized network.

CYFS Core Dev Team 2k Jul 6, 2023
Test cargo crates in different envs & via different methods

Test cargo crates in different envs & via different methods

@Vlad@ 2 Mar 22, 2022