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