Tokio GRPC Server Streaming --- Problem with the latest version

I followed the blog at Beginners guide to grpc and Rust and the corresponding code at Github code

I was able to compile and run the code in the github using the checked in Cargo,toml. Since the versions were old I thought I would use the latest versions of the crates but that is causing the code to not compile

#These work . 
[dependencies]

prost = "0.6.1"

tonic = {version="0.2.0",features = ["tls"]}

tokio = {version="0.2.18",features = ["stream", "macros"]}

futures = "0.3"

[build-dependencies]

tonic-build = "0.2.0"

#These do not work 
#[dependencies]

#prost = "0.7.0"

#tonic = "0.4.1"

#tokio = { version = "1.4.0", features = ["full"] }

#futures = "0.3.13"

#[build-dependencies]

#tonic-build = "0.4.1"

I get the following error

type SendStreamStream = mpsc::Receiver<Result<SayResponse,Status>>;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
error[E0277]: the trait bound `tokio::sync::mpsc::Receiver<std::result::Result<SayResponse, Status>>: tonic::codegen::Stream` is not satisfied

Could you help me resolve these errors ?

Try using a tokio_stream::wrappers::ReceiverStream instead.

For future questions, please be aware that what you posted is not the full error message. We will often not be able to tell what is wrong when given only that small part of the error.

2 Likes