|
|
@ -2,15 +2,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
use std::fmt;
|
|
|
|
use std::fmt;
|
|
|
|
use std::io::{BufRead, BufReader, BufWriter, ErrorKind, Write};
|
|
|
|
use std::io::{BufRead, BufReader, BufWriter, ErrorKind, Write};
|
|
|
|
use std::net::SocketAddr;
|
|
|
|
use std::net::{Shutdown, SocketAddr};
|
|
|
|
|
|
|
|
|
|
|
|
use log::error;
|
|
|
|
use log::error;
|
|
|
|
|
|
|
|
|
|
|
|
use mio::Token;
|
|
|
|
|
|
|
|
use mio::net::TcpStream;
|
|
|
|
use mio::net::TcpStream;
|
|
|
|
|
|
|
|
use mio::Token;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::result::RudeResult;
|
|
|
|
use crate::result::RudeResult;
|
|
|
|
use crate::state::*;
|
|
|
|
use crate::state::*;
|
|
|
|
|
|
|
|
use crate::try_log;
|
|
|
|
|
|
|
|
|
|
|
|
/// `Client` struct for storing information about a connected client, also
|
|
|
|
/// `Client` struct for storing information about a connected client, also
|
|
|
|
/// a few helper functions for communicating with the client.
|
|
|
|
/// a few helper functions for communicating with the client.
|
|
|
@ -83,4 +84,11 @@ impl Client {
|
|
|
|
fn prompt(&self) -> &str {
|
|
|
|
fn prompt(&self) -> &str {
|
|
|
|
"\n> "
|
|
|
|
"\n> "
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn close(&self) -> RudeResult<()> {
|
|
|
|
|
|
|
|
Ok(try_log!(
|
|
|
|
|
|
|
|
self.socket.shutdown(Shutdown::Both),
|
|
|
|
|
|
|
|
"Unable to close socket"
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|