1use serde::{Deserialize, Serialize};
7use tokio::{
8 io::{self, BufReader, ReadHalf, WriteHalf},
9 net::TcpStream,
10};
11
12pub struct TcpHandler {
16 pub reader: BufReader<ReadHalf<TcpStream>>,
18
19 pub writer: WriteHalf<TcpStream>,
21}
22
23impl From<TcpStream> for TcpHandler {
24 fn from(stream: TcpStream) -> Self {
25 let (reader, writer) = io::split(stream);
26 let reader = BufReader::new(reader);
27 Self { reader, writer }
28 }
29}
30
31#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
33pub struct TcpConfig {
34 pub host: String,
36
37 pub port: u16,
39}