xref: /tonic/examples/src/helloworld/client.rs (revision 4e5c6c8f)
1 use hello_world::greeter_client::GreeterClient;
2 use hello_world::HelloRequest;
3 
4 pub mod hello_world {
5     tonic::include_proto!("helloworld");
6 }
7 
8 #[tokio::main]
main() -> Result<(), Box<dyn std::error::Error>>9 async fn main() -> Result<(), Box<dyn std::error::Error>> {
10     let mut client = GreeterClient::connect("http://[::1]:50051").await?;
11 
12     let request = tonic::Request::new(HelloRequest {
13         name: "Tonic".into(),
14     });
15 
16     let response = client.say_hello(request).await?;
17 
18     println!("RESPONSE={:?}", response);
19 
20     Ok(())
21 }
22