YuhanLiin/micropb

Rust Protobuf library targetting embedded systems and no_std environments without an allocator

Rust

142

605 commits

updated Jul 23, 2026

See the code

README

GitHub Actions Workflow Status docs.rs Crates.io Version

Micropb

micropb is a Rust implementation of the Protobuf format, with a focus on embedded environments. micropb generates a Rust module from .proto files.

Unlike other Rust Protobuf libraries, micropb is aimed for constrained environments where no allocator is available. As such, micropb offers a different set of tradeoffs compared to other Protobuf libraries.

Advantages

  • Supports no-std and no-alloc environments.
  • Reduced memory usage for generated code, especially for optional fields.
  • Allows both statically-allocated containers (heapless, arrayvec) or dynamically-allocated containers from alloc.
  • Code generator is highly configurable.
  • Type-safe open enums, rather than i32.
  • Fields can have custom handlers with user-defined encoding and decoding behaviour.
  • Supports different data sources for encoding and decoding, abstracted behind the PbRead and PbWrite traits.
  • Supports caching of message field lengths during encoding, improving performance on deeply nested message structures.

Limitations

  • Does not provide a built-in RPC implementation, but supports custom code generation from Protobuf services.
  • Does not support Protobuf extensions.
  • Does not support closed enums.
  • No reflection capabilities.
  • string, bytes, repeated, and map fields require some basic user configuration to get working.

Editions Support

micropb supports the field_presence and repeated_field_encoding features of Protobuf Editions. The enum_type, message_encoding, and utf8_validation features are ignored, because micropb does not support customizing those features. The other standard Editions features are not relevant to code generation.

Overview

The micropb project consists of two crates:

  • micropb: Encoding and decoding routines for the Protobuf wire data. The generated module will assume it's been imported as a regular dependency.

  • micropb-gen: Code generation tool that generates a Rust module from a set of .proto files. Include this as a build dependency.

For a concrete example of micropb on an embedded application, see arm-app.

Documentation

Documentation is at docs.rs.

MSRV

The oldest version of Rust that micropb supports is 1.88.0.

License

micropb is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

embedded-systems
protobuf
protobuf3
rust

Contributors

YuhanLiin

600 commits

joelsa

3 commits

iaudouard

1 commits

scootermon

1 commits

Languages

Rust

100.0%

YuhanLiin/micropb

Rust Protobuf library targetting embedded systems and no_std environments without an allocator

Rust

142

605 commits

updated Jul 23, 2026

See the code

README

GitHub Actions Workflow Status docs.rs Crates.io Version

Micropb

micropb is a Rust implementation of the Protobuf format, with a focus on embedded environments. micropb generates a Rust module from .proto files.

Unlike other Rust Protobuf libraries, micropb is aimed for constrained environments where no allocator is available. As such, micropb offers a different set of tradeoffs compared to other Protobuf libraries.

Advantages

  • Supports no-std and no-alloc environments.
  • Reduced memory usage for generated code, especially for optional fields.
  • Allows both statically-allocated containers (heapless, arrayvec) or dynamically-allocated containers from alloc.
  • Code generator is highly configurable.
  • Type-safe open enums, rather than i32.
  • Fields can have custom handlers with user-defined encoding and decoding behaviour.
  • Supports different data sources for encoding and decoding, abstracted behind the PbRead and PbWrite traits.
  • Supports caching of message field lengths during encoding, improving performance on deeply nested message structures.

Limitations

  • Does not provide a built-in RPC implementation, but supports custom code generation from Protobuf services.
  • Does not support Protobuf extensions.
  • Does not support closed enums.
  • No reflection capabilities.
  • string, bytes, repeated, and map fields require some basic user configuration to get working.

Editions Support

micropb supports the field_presence and repeated_field_encoding features of Protobuf Editions. The enum_type, message_encoding, and utf8_validation features are ignored, because micropb does not support customizing those features. The other standard Editions features are not relevant to code generation.

Overview

The micropb project consists of two crates:

  • micropb: Encoding and decoding routines for the Protobuf wire data. The generated module will assume it's been imported as a regular dependency.

  • micropb-gen: Code generation tool that generates a Rust module from a set of .proto files. Include this as a build dependency.

For a concrete example of micropb on an embedded application, see arm-app.

Documentation

Documentation is at docs.rs.

MSRV

The oldest version of Rust that micropb supports is 1.88.0.

License

micropb is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

embedded-systems
protobuf
protobuf3
rust

Contributors

YuhanLiin

600 commits

joelsa

3 commits

iaudouard

1 commits

scootermon

1 commits

Languages

Rust

100.0%