From 0a258a0a2128749be84448bdd6819eaff38d4c70 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Fri, 23 Jan 2015 10:21:08 -0800 Subject: [PATCH] Fix for upstream changes --- src/bn/mod.rs | 2 +- src/ssl/error.rs | 7 +++++++ src/ssl/mod.rs | 18 +++++++++--------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/bn/mod.rs b/src/bn/mod.rs index 84a57c4a..3a5f231e 100644 --- a/src/bn/mod.rs +++ b/src/bn/mod.rs @@ -438,7 +438,7 @@ impl BigNum { } } -impl fmt::Show for BigNum { +impl fmt::Debug for BigNum { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.to_dec_str()) } diff --git a/src/ssl/error.rs b/src/ssl/error.rs index c52879a0..4f05e449 100644 --- a/src/ssl/error.rs +++ b/src/ssl/error.rs @@ -3,6 +3,7 @@ pub use self::OpensslError::*; use libc::c_ulong; use std::error; +use std::fmt; use std::ffi::c_str_to_bytes; use std::io::IoError; @@ -19,6 +20,12 @@ pub enum SslError { OpenSslErrors(Vec) } +impl fmt::Display for SslError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.write_str(error::Error::description(self)) + } +} + impl error::Error for SslError { fn description(&self) -> &str { match *self { diff --git a/src/ssl/mod.rs b/src/ssl/mod.rs index c4e41055..3e7cd182 100644 --- a/src/ssl/mod.rs +++ b/src/ssl/mod.rs @@ -35,7 +35,7 @@ fn init() { /// Determines the SSL method supported #[allow(non_camel_case_types)] -#[derive(Copy, Clone, Show, Hash, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub enum SslMethod { #[cfg(feature = "sslv2")] /// Only support the SSLv2 protocol, requires `feature="sslv2"` @@ -71,7 +71,7 @@ impl SslMethod { } /// Determines the type of certificate verification used -#[derive(Copy, Clone, Show)] +#[derive(Copy, Clone, Debug)] #[repr(i32)] pub enum SslVerifyMode { /// Verify that the server's certificate is trusted @@ -178,7 +178,7 @@ pub struct SslContext { } // TODO: add useful info here -impl fmt::Show for SslContext { +impl fmt::Debug for SslContext { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "SslContext") } @@ -301,7 +301,7 @@ pub struct Ssl { } // TODO: put useful information here -impl fmt::Show for Ssl { +impl fmt::Debug for Ssl { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "Ssl") } @@ -404,7 +404,7 @@ impl Ssl { } -#[derive(FromPrimitive, Show)] +#[derive(FromPrimitive, Debug)] #[repr(i32)] enum LibSslError { ErrorNone = ffi::SSL_ERROR_NONE, @@ -426,7 +426,7 @@ pub struct SslStream { buf: Vec } -impl fmt::Show for SslStream where S: fmt::Show { +impl fmt::Debug for SslStream where S: fmt::Debug { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { write!(fmt, "SslStream {{ stream: {:?}, ssl: {:?} }}", self.stream, self.ssl) } @@ -510,7 +510,7 @@ impl SslStream { LibSslError::ErrorWantRead => { try_ssl_stream!(self.flush()); let len = try_ssl_stream!(self.stream.read(self.buf.as_mut_slice())); - self.ssl.get_rbio().write(self.buf.slice_to(len)); + self.ssl.get_rbio().write(&self.buf[..len]); } LibSslError::ErrorWantWrite => { try_ssl_stream!(self.flush()) } LibSslError::ErrorZeroReturn => return Err(SslSessionClosed), @@ -523,7 +523,7 @@ impl SslStream { fn write_through(&mut self) -> IoResult<()> { loop { match self.ssl.get_wbio().read(self.buf.as_mut_slice()) { - Some(len) => try!(self.stream.write(self.buf.slice_to(len))), + Some(len) => try!(self.stream.write(&self.buf[..len])), None => break }; } @@ -587,7 +587,7 @@ impl Writer for SslStream { } /// A utility type to help in cases where the use of SSL is decided at runtime. -#[derive(Show)] +#[derive(Debug)] pub enum MaybeSslStream where S: Stream { /// A connection using SSL Ssl(SslStream),