1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
pub mod configuration;
mod network;

pub extern crate async_trait;
pub extern crate tokio;
pub extern crate tcp_handler;
#[cfg(feature = "serde")]
pub extern crate serde;

use async_trait::async_trait;
use tcp_handler::common::{AesCipher, StarterError};
use tokio::net::{TcpStream, ToSocketAddrs};

pub use network::{send, recv};
use crate::network::start_client;

#[async_trait]
pub trait Client {
    fn get_identifier(&self) -> &'static str;

    fn get_version(&self) -> &'static str;

    async fn connect<A: ToSocketAddrs + Send>(&self, addr: A) -> Result<(TcpStream, AesCipher), StarterError> {
        start_client(self, addr).await
    }
}