chiral_client/api/
client.rs

1use tonic::transport::Channel;
2pub use crate::proto::chiral; 
3pub use chiral::chiral_client::ChiralClient;
4
5pub async fn create_client(url: &str) -> Result<ChiralClient<Channel>, Box<dyn std::error::Error>> {
6    Ok(ChiralClient::connect(url.to_string()).await?)
7}
8
9#[cfg(test)]
10mod tests{
11    use super::create_client;
12    #[tokio::test]
13    async fn test_create_client(){
14        dotenvy::from_filename(".env.staging").ok();
15        let url = std::env::var("CHIRAL_STAGING_API_URL")
16            .expect("Missing env")
17            .trim() 
18            .to_string();
19
20        let result = create_client(&url).await;
21        assert!(result.is_ok(), "Client creation failed: {:?}", result.err());
22    }
23}