16 releases
0.1.15 | Mar 16, 2025 |
---|---|
0.1.14 | Mar 15, 2025 |
#371 in Procedural macros
1,241 downloads per month
31KB
477 lines
proto_convert_derive
Automatically derive conversions between Protobuf-compiled prost types and your native Rust types.
Overview
proto_convert_derive
is a procedural macro for bidirectional conversions between Protobuf-generated types (prost
) and Rust structs. This reduces boilerplate and handles proto3's lack of required
fields (which result in Option
and lots .expect
or if let Some
in your code. This macro simply .expect
s types.
Key Features
- Automatically implements
From<Proto>
for Rust types and vice versa. - Supports collections like
Vec<Proto>
- Direct mapping for primitive types.
- Unwraps optional fields with
.expect
. - Supports newtype wrappers.
- Customizable Protobuf module (default is
proto
via#[proto(module = "your_module")]
). - Ignore individual fields
#[proto(ignore)]
Usage
Head to the examples.
Dependencies
~200–630KB
~15K SLoC