PROST! a Protocol Buffers implementation for the Rust Language
Questions tagged [prost]
23 questions
7
votes
1 answer
How can I deserialize a Prost enum with serde?
I'm using [prost] to generate structs from protobuf. One of those structs is quite simple:
enum Direction {
up = 0;
down = 1;
sideways = 2;
}
This generates code which looks like:
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd,…

kalzen
- 343
- 4
- 12
5
votes
1 answer
How to import .proto when working with prost and tonic in rust?
I'm trying to build a simple gRPC client in rust using crates prost and tonic. My proto definitions are quite simple, but I suddenly stuck with using messages imported from other proto.
// file src/protos/types.proto
syntax = "proto3";
package…

ie.
- 5,982
- 1
- 29
- 44
3
votes
1 answer
How can I pass data to a protobuf `oneof` in tonic?
How can I pass data to a protobuf oneof in tonic?
I couldn't find any instruction or example in the docs.

yukashima huksay
- 5,834
- 7
- 45
- 78
2
votes
1 answer
How to prevent cargo clippy from analyizing generated prost files
I am using prost to generate rust classes for protobufs. I want clippy to ignore these generated files and I'm having trouble figuring out how to make clippy ignore them.
In my lib.rs file, I have
pub mod modes {
#[allow(clippy)]
…

Connor
- 545
- 4
- 20
2
votes
1 answer
Using relative paths works for "cargo build" but not for "cargo publish"
I have a project that holds some protobuf definitions and builds code for multiple (Python and Rust) languages. The folder structure is like this:
root/
proto/
my.proto
python/
rust/
Cargo.toml
build.rs
...
I'm using prost to generate…

Achim
- 15,415
- 15
- 80
- 144
2
votes
3 answers
Best way to populate a struct from a similar struct?
I am new to Rust, and am attempting to take a struct returned from a library (referred to as source struct) and convert it into protobuf message using prost. The goal is to take the source struct, map the source struct types to the protobuf message…

gsundberg
- 437
- 1
- 4
- 14
2
votes
0 answers
Rust Tonic gRPC "transport error" / " Kind(BrokenPipe)" only when running in Docker
this one is weirdo and bugging me quite a bit. I'm learning gRPC with tonic & prost. I've followed a tutorial and basically wrote a simple voting server & client. Locally, it runs perfectly fine. Next, I dockerized the voting service, and only when…

Marvin.Hansen
- 1,436
- 1
- 15
- 29
2
votes
2 answers
the trait `std::marker::Copy` is not implemented for Type
I'm trying to move some data around b/w different threads but am getting the ole Copy trait-not-implemented error. Here's some code:
use std::future::Future;
use std::marker::PhantomData;
use std::sync::{Arc, Mutex};
/// Start external crates…

Seg
- 23
- 2
- 4
2
votes
0 answers
How to share .proto messages across multiple microservices?
I'm trying to create a bunch of microservices. Most grpc messages use this message
message i18n {
map translations = 0;
}
i18n also implements additional methods to choose the right key for the request context. In this way
I would…

user2726621
- 41
- 3
1
vote
3 answers
How to convert a `serde_json::Value ` to a `prost_types::Struct` in Rust?
fn to_struct(json: serde_json::Value) -> prost_types::Struct {
// How to implement it?
}
Is there any crate to do it?

Yang Bo
- 3,586
- 3
- 22
- 35
1
vote
0 answers
How to get my prost_types::DescriptorProto for my message from .proto file?
How to get my prost_types::DescriptorProto for my message from .proto file?
I have written a rust program to invoke google bigquery storage write API via grpc w/ protobuf by gcloud-sdk…

WENPIN1
- 21
- 3
1
vote
0 answers
Rust converting a struct to key value pair where the field is not none
I have a struct generated by prost (protobuf implementation based on proto).
pub struct Data {
#[prost(string, tag="1")]
pub field1: ::prost::alloc::string::String,
#[prost(message, optional, tag="2")]
pub struct_2:…

Abhilash Gopalakrishna
- 910
- 2
- 22
- 52
1
vote
1 answer
Rust tonic and prost_types conversion
I'm using tonic framework, a rust grpc server implementation. In the generated rust code from the proto file, I have a struct which has a field:
#[prost(message, optional, tag="3")]
pub data: ::core::option::Option<::prost_types::Value>,
generated…

Noor Thabit
- 79
- 2
- 10
1
vote
2 answers
Rust / Prost : How do add Debug to structs & unions?
It looks like the prost protobuf generator only adds derive(Debug) to generated enum types (and only enums not inside a pub mod block). None of the generated structs, or unions have it applied. How can I get prost to add it to everything?
Using…

West_JR
- 372
- 2
- 11
1
vote
1 answer
Prost - the `encode` method cannot be invoked on a trait object
I'mm trying to write a generic function to encode and decode prost messages with the below code.
pub fn write_message(&mut self, message: &mut dyn prost::Message) -> std::io::Result {
let mut buf: Vec = Vec::new();
…

Sanka Darshana
- 1,391
- 1
- 23
- 41