MCPcopy Index your code
hub / github.com/YuhanLiin/micropb

github.com/YuhanLiin/micropb @v0.5.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.1 ↗ · + Follow
1,106 symbols 2,672 edges 67 files 130 documented · 12%
What it actually does AI analysis from the code graph — generated when you open this
loading…
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.
  • 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.

Limitations

  • Does not support Protobuf Editions, RPC, or extensions.
  • No reflection capabilities.
  • string, bytes, repeated, and map fields require some basic user configuration to get working.

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.85.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.

Extension points exported contracts — how you extend this code

PbString (Interface)
Container that stores a string. Represents Protobuf `string` field. # Safety The bytes in the container must be valid U [11 …
micropb/src/container.rs
TryIntoTokens (Interface)
(no doc) [1 implementers]
micropb-gen/src/utils.rs
PbBytes (Interface)
Container that stores a sequence of arbitrary bytes. Represents Protobuf `bytes` field. `PbBytes` is a subtrait of [`Pb [6 …
micropb/src/container.rs
PbWrite (Interface)
A writer to which Protobuf data is written, similar to [`std::io::Write`]. [`PbEncoder`] uses this trait as the interfa [6 …
micropb/src/encode.rs
MessageDecode (Interface)
Protobuf message that can be decoded from the wire. Implementations are auto-generated by `micropb-gen`. [35 implementers]
micropb/src/message.rs
PbVec (Interface)
Generic vector that stores multiple elements. Represents repeated field. [5 implementers]
micropb/src/container.rs

Core symbols most depended-on inside this repo

configure
called by 132
micropb-gen/src/lib.rs
len
called by 105
micropb/src/decode.rs
bytes_read
called by 70
micropb/src/decode.rs
as_reader
called by 69
micropb/src/decode.rs
decode_len_delimited
called by 58
micropb/src/message.rs
decode
called by 58
tests/basic-proto/src/extern_import.rs
decode_int32
called by 47
micropb/src/decode.rs
encode
called by 44
tests/basic-proto/src/extern_import.rs

Shape

Method 679
Function 318
Class 80
Enum 17
Interface 12

Languages

Rust100%

Modules by API surface

micropb-gen/src/descriptor.rs475 symbols
micropb/src/decode.rs65 symbols
micropb/src/encode.rs45 symbols
micropb-gen/src/generator.rs39 symbols
micropb-gen/src/lib.rs30 symbols
micropb-gen/src/generator/graph.rs28 symbols
micropb-gen/tests/error.rs27 symbols
tests/basic-proto/build.rs26 symbols
micropb-gen/src/generator/field.rs25 symbols
micropb-gen/src/generator/type_spec.rs24 symbols
micropb-gen/src/config.rs24 symbols
micropb-gen/src/generator/message.rs23 symbols

For agents

$ claude mcp add micropb \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page