Create Client struct
This commit is contained in:
parent
fb1908cd17
commit
41bb4b9ae7
20
src/lib.rs
20
src/lib.rs
|
@ -1,8 +1,14 @@
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = 2 + 2;
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
use std::net::TcpStream;
|
||||
use std::io::Error;
|
||||
|
||||
pub struct Client {
|
||||
stream: TcpStream
|
||||
}
|
||||
|
||||
impl Client {
|
||||
pub fn new(host: &str, port: &str) -> Result<Self, Error> {
|
||||
let mut stream = TcpStream::connect(format!("{}:{}", host, port))?;
|
||||
|
||||
Ok(Self { stream })
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue