use crate::net::protocol::{Request, Response};
use async_trait::async_trait;
use std::net::SocketAddr;
#[async_trait]
pub trait GenClient: Sized {
async fn connect(addr: SocketAddr) -> std::io::Result<Self>;
async fn send_request(&mut self, request: Request) -> std::io::Result<()>;
async fn await_response(&mut self) -> anyhow::Result<Response>;
async fn exchange(&mut self, request: Request) -> anyhow::Result<Response> {
self.send_request(request).await?;
let response = self.await_response().await?;
Ok(response)
}
}