1 use hello_world::greeter_client::GreeterClient; 2 use hello_world::HelloRequest; 3 use tonic::transport::Channel; 4 5 pub mod hello_world { 6 tonic::include_proto!("helloworld"); 7 } 8 9 #[tokio::main] 10 async fn main() -> Result<(), Box<dyn std::error::Error>> { 11 let channel = Channel::builder("http://[::1]:50051".parse().unwrap()) 12 .connect() 13 .await 14 .unwrap(); 15 16 let mut client = GreeterClient::new(channel).send_gzip().accept_gzip(); 17 18 let request = tonic::Request::new(HelloRequest { 19 name: "Tonic".into(), 20 }); 21 22 let response = client.say_hello(request).await?; 23 24 dbg!(response); 25 26 Ok(()) 27 } 28