#protoc #serialization #protobuf #proto #buffer #generate #api

build protoc-rust

protoc --rust_out=... available as API. protoc needs to be in $PATH, protoc-gen-run does not.

81 stable releases

3.0.0-alpha.2 Nov 1, 2021
2.28.0 Sep 26, 2022
2.27.1 Feb 5, 2022
2.25.2 Oct 24, 2021
1.4.1 Jun 24, 2017

#2509 in Encoding

Download history 4947/week @ 2024-10-17 4722/week @ 2024-10-24 4350/week @ 2024-10-31 4726/week @ 2024-11-07 5482/week @ 2024-11-14 4007/week @ 2024-11-21 4021/week @ 2024-11-28 4494/week @ 2024-12-05 6391/week @ 2024-12-12 3414/week @ 2024-12-19 2662/week @ 2024-12-26 4110/week @ 2025-01-02 4738/week @ 2025-01-09 5307/week @ 2025-01-16 4382/week @ 2025-01-23 3447/week @ 2025-01-30

18,732 downloads per month
Used in fewer than 53 crates

MIT license

230KB
5.5K SLoC

API to generate .rs files

API to generate .rs files to be used e. g. from build.rs.

Example code:

extern crate protoc_rust;

use protoc_rust::Customize;

fn main() {
    protoc_rust::Codegen::new()
        .out_dir("src/protos")
        .inputs(&["protos/a.proto", "protos/b.proto"])
        .include("protos")
        .run()
        .expect("protoc");
}

And in Cargo.toml:

[build-dependencies]
protoc-rust = "2.0"

Note 1: This API requires protoc command present in $PATH. Although protoc-gen-rust command is not needed.

Note 2: Is advisable that protoc-rust build-dependecy version be the same as protobuf dependency.

The alternative is to use pure-rust .proto parser and code generator.


lib.rs:

API to generate .rs files.

This API requires protoc command present in $PATH or passed explicitly to Codegen object.

extern crate protoc_rust;

fn main() {
    protoc_rust::Codegen::new()
        .out_dir("src/protos")
        .inputs(&["protos/a.proto", "protos/b.proto"])
        .include("protos")
        .run()
        .expect("Running protoc failed.");
}

It is advisable that protoc-rust build-dependecy version be the same as protobuf dependency.

The alternative is to use protobuf-codegen-pure.

Dependencies

~4–12MB
~172K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy