0

I am using tonic:2.0 for grpc implementation, I have created proto with service userdetails with message request username and user email as shown in below proto file with rust implementation. I am facing error when I use request request: Request<userRequest> multiple time. Please help me how I can solve this issue

syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.grpc.examples.userDetails";
option java_outer_classname = "providerUserDetails";

package provider;


service Provider {
  // Sends a greeting
  rpc userdetails (userRequest) returns (userResponse) {}

}

// The request message containing the user's name.
message userRequest {
  string username = 1;
  string useremail =2;
}

message userResponse {
  bool message =1;
}

Rust tonic implementation for proto

    async fn create_contract(
        &self,
        request: Request<userRequest>, // Accept request of type userDetails
    ) -> Result<Response<userResponse>, Status> {
        let mut bc = self.bc.lock().unwrap();

        let user_name = request.into_inner().username;
        let user_email = request.into_inner().useremail;

    }

> Error: request.into_inner().useremail;
    |                   ^^^^^^^ value used here after move value used here after move
nagaraj
  • 797
  • 1
  • 6
  • 29
  • 1
    I have no idea about this framework, but probably: `let msg = request.into_inner();` and then use `msg` as many times as you need. – rodrigo Apr 20 '20 at 14:27
  • i tried as you mentioned above, still facing same error at parameter ``` request: Request``` & let msg = request.into_inner(); this two request throws same error as i mentioned above – nagaraj Apr 20 '20 at 15:27
  • 1
    `into_inner()` consumes the `Result` so you can call it once. If you are calling it just once and the error is still present, please update the code in the question, and copy the full error message, because now I think it is cropped. – rodrigo Apr 20 '20 at 15:44
  • @rodrigo Thank you for replay, As you mention above code, It works fine. I needed some changes in my code. – nagaraj Apr 21 '20 at 01:52

0 Answers0