Skip to content

Broken Example Code Due to Missing Module in crates.io Version #2177

Open
@arthurgubaidullin

Description

@arthurgubaidullin

Bug Report

Version

0.12.3

Platform

aarch64 GNU/Linux

Crates

https://crates.io/crates/tonic

Description

I tried running the example code from this repository, but it doesn't work because a required module is missing, and it isn't available in the version on crates.io. I spent hours troubleshooting and found that the latest release was in September 2024. It turns out that the examples are using a version that isn't from crates.io.

I expect the example code to be functional and up to date. The links in the documentation lead to non-working examples. Please update the examples or provide guidance on how to resolve the issue.

error[E0432]: unresolved import `tonic::service::LayerExt`
 --> experiments/grpc-server/src/main.rs:1:13
  |
1 | use tonic::{service::LayerExt as _, transport::Server, Request, Response, Status};
  |             ^^^^^^^^^^^^^^^^^^^^^^ no `LayerExt` in `service`

error[E0599]: no method named `named_layer` found for struct `Stack` in the current scope
  --> experiments/grpc-server/src/main.rs:42:10
   |
38 |       let greeter = tower::ServiceBuilder::new()
   |  ___________________-
39 | |         .layer(tower_http::cors::CorsLayer::new())
40 | |         .layer(tonic_web::GrpcWebLayer::new())
41 | |         .into_inner()
42 | |         .named_layer(GreeterServer::new(greeter));
   | |         -^^^^^^^^^^^ method not found in `Stack<GrpcWebLayer, Stack<CorsLayer, Identity>>`
   | |_________|
   |

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.

Related PR: #1966

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions