使用rust-protobuf时我作为参数传递什么?

问题描述 投票:3回答:1

我试图跟随qazxsw poi生成Rust protobuf文件:

API to generate .rs files

用于生成要使用的instructions文件的API。 G。 .rs

示例代码:

from
  build.rs

extern crate protoc_rust; protoc_rust::run(protoc_rust::Args { out_dir: "src/protos", input: &["protos/a.proto", "b.proto"], includes: &["protos"], }).expect("protoc");

Cargo.toml

请注意,此API需要[build-dependencies] protoc-rust = "1.4" 中的protoc命令。虽然不需要$PATH命令。

没有明确的文档说明这些参数的传递内容。第一个(protoc-gen-rust)显然是生成文件的目录.out_dir看起来像用于生成的input文件列表。在这个例子中,第一个有一个目录,而第二个没有。我是否需要为每个目录或第一个目录传递一个目录? .proto真的让我感到困惑。这是要查看的文件夹列表吗?如果我在这里添加includes,我可以省略protos的元素吗?

rust protocol-buffers
1个回答
6
投票

如果你看一下源代码(input),你会看到:

source

所以这些论点的含义是:

#[derive(Debug, Default)] pub struct Args<'a> { /// --lang_out= param pub out_dir: &'a str, /// -I args pub includes: &'a [&'a str], /// List of .proto files to compile pub input: &'a [&'a str], } :生成文件的位置

out_dirincludes):protoc将搜索进口的地方(-I

documentation:要编译的input文件列表

© www.soinside.com 2019 - 2024. All rights reserved.