Please, I have a microservice written in Rust that uses Tonic (gRPC) to access a SQL Server database. I have validated the versions and files, but I am unable to access the internal functions of the file generated by Tonic.
I get the following error when trying to compile my code: error[E0433]: failed to resolve: use of undeclared crate or module vehicleservice –> src/main.rs:9:5 9 | use vehicleservice::vehicle_service_server::{VehicleServiceServer, VehicleService}; | ^^^^^^^^^^^^^^ use of undeclared crate or module vehicleservice help: there is a crate or module with a similar name 9 | use VehicleService::vehicle_service_server::{VehicleServiceServer, VehicleService};
Here is the relevant part of my main.rs
file:
include!(concat!(env!(“OUT_DIR”), “/vehicleservice.rs”));
use tonic::{transport::Server, Request, Response, Status};
use uuid::Uuid; use tiberius::{Client, Config};
use tokio::net::TcpStream;
use tokio_util::compat::TokioAsyncWriteCompatExt;
use async_trait::async_trait;
use vehicleservice::vehicle_service_server::{VehicleServiceServer, VehicleService};
use vehicleservice::{Vehicle, ListVehiclesResponse};
And here is the relevant part of my vehicleservice.rs
file generated by Tonic:
pub mod vehicle_service_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
/// Generated trait containing gRPC methods that should be implemented for use with VehicleServiceServer.
#[async_trait]
pub trait VehicleService: Send + Sync + 'static {
async fn list_vehicles(
&self,
request: tonic::Request<()>,
) -> std::result::Result<
tonic::Response<super::ListVehiclesResponse>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct VehicleServiceServer<T: VehicleService> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
I have tried checking if the vehicleservice.rs
file is in the correct directory and if the include!
statement is pointing to the correct path. I have also tried checking if the module name is correct and matches the file name. I have tried recompiling the gRPC service definition file to ensure that the vehicleservice.rs
file is generated correctly. I have also checked if my build.rs
file is correctly configured to generate the vehicleservice.rs
file. I have tried updating all my dependencies to the latest versions. I have even tried creating a minimal test project with only the necessary code to reproduce the problem. However, none of these solutions have worked.
Has anyone faced a similar issue or have any suggestions on how to fix this problem?