rusty_tracks/connection/
client.rs

1use std::net::TcpStream;
2use crate::connection::Connection;
3
4pub struct Client{
5    host: String,
6    port: u16,
7}
8
9
10impl Client {
11    pub fn new(host: &str, port: u16) -> Self {
12        Client{ host: host.to_string(), port }
13    }
14
15    pub fn connect(&self) -> Result<Connection, String> {
16        let stream = TcpStream::connect((self.host.clone(), self.port)).unwrap();
17        Connection::new(&self.host, self.port, stream)
18    }
19
20}
21