#[tokio::test] async fn test_hello_service() { #[urpc::service] trait Hello { type Error = (); async fn hello(name: String) -> String; } struct HelloServer; impl Hello for HelloServer { async fn hello(&self, _ctx: urpc::Context, name: String) -> Result { Ok(format!("Hello, {name}!")) } } let listener = urpc::tcp::bind("0.0.0.0:3000").await.unwrap(); // spawn the server tokio::spawn(async move { urpc::Server::default() .with_listener(listener) .with_service(HelloServer.into_service()) .serve() .await }); // create a client let channel = urpc::ClientChannel::new(urpc::tcp::connect("127.0.0.1:3000").await.unwrap()); let client = HelloClient::new(channel); let greeting = client.hello("World".into()).await.unwrap(); assert_eq!(greeting, "Hello, World!"); }