Initial work on connecting to servers
This commit is contained in:
parent
ba1fe8e766
commit
458a36bbf2
|
@ -631,6 +631,7 @@ pub enum State {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
Err(String),
|
Err(String),
|
||||||
|
Disconnect(format::Component),
|
||||||
IOError(io::Error),
|
IOError(io::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,6 +645,7 @@ impl ::std::error::Error for Error {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Err(ref val) => &val[..],
|
Error::Err(ref val) => &val[..],
|
||||||
|
Error::Disconnect(_) => "Disconnect",
|
||||||
Error::IOError(ref e) => e.description(),
|
Error::IOError(ref e) => e.description(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -653,6 +655,7 @@ impl ::std::fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Err(ref val) => write!(f, "protocol error: {}", val),
|
Error::Err(ref val) => write!(f, "protocol error: {}", val),
|
||||||
|
Error::Disconnect(ref val) => write!(f, "{}", val),
|
||||||
Error::IOError(ref e) => e.fmt(f),
|
Error::IOError(ref e) => e.fmt(f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -660,10 +663,10 @@ impl ::std::fmt::Display for Error {
|
||||||
|
|
||||||
pub struct Conn {
|
pub struct Conn {
|
||||||
stream: TcpStream,
|
stream: TcpStream,
|
||||||
host: String,
|
pub host: String,
|
||||||
port: u16,
|
pub port: u16,
|
||||||
direction: Direction,
|
direction: Direction,
|
||||||
state: State,
|
pub state: State,
|
||||||
|
|
||||||
cipher: Option<openssl::EVPCipher>,
|
cipher: Option<openssl::EVPCipher>,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue