Fix for upstream changes

This commit is contained in:
Steven Fackler 2015-01-23 10:21:08 -08:00
parent 0afb82bc4b
commit 0a258a0a21
3 changed files with 17 additions and 10 deletions

View File

@ -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 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.to_dec_str()) write!(f, "{}", self.to_dec_str())
} }

View File

@ -3,6 +3,7 @@ pub use self::OpensslError::*;
use libc::c_ulong; use libc::c_ulong;
use std::error; use std::error;
use std::fmt;
use std::ffi::c_str_to_bytes; use std::ffi::c_str_to_bytes;
use std::io::IoError; use std::io::IoError;
@ -19,6 +20,12 @@ pub enum SslError {
OpenSslErrors(Vec<OpensslError>) OpenSslErrors(Vec<OpensslError>)
} }
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 { impl error::Error for SslError {
fn description(&self) -> &str { fn description(&self) -> &str {
match *self { match *self {

View File

@ -35,7 +35,7 @@ fn init() {
/// Determines the SSL method supported /// Determines the SSL method supported
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Copy, Clone, Show, Hash, PartialEq, Eq)] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub enum SslMethod { pub enum SslMethod {
#[cfg(feature = "sslv2")] #[cfg(feature = "sslv2")]
/// Only support the SSLv2 protocol, requires `feature="sslv2"` /// Only support the SSLv2 protocol, requires `feature="sslv2"`
@ -71,7 +71,7 @@ impl SslMethod {
} }
/// Determines the type of certificate verification used /// Determines the type of certificate verification used
#[derive(Copy, Clone, Show)] #[derive(Copy, Clone, Debug)]
#[repr(i32)] #[repr(i32)]
pub enum SslVerifyMode { pub enum SslVerifyMode {
/// Verify that the server's certificate is trusted /// Verify that the server's certificate is trusted
@ -178,7 +178,7 @@ pub struct SslContext {
} }
// TODO: add useful info here // TODO: add useful info here
impl fmt::Show for SslContext { impl fmt::Debug for SslContext {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "SslContext") write!(fmt, "SslContext")
} }
@ -301,7 +301,7 @@ pub struct Ssl {
} }
// TODO: put useful information here // TODO: put useful information here
impl fmt::Show for Ssl { impl fmt::Debug for Ssl {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "Ssl") write!(fmt, "Ssl")
} }
@ -404,7 +404,7 @@ impl Ssl {
} }
#[derive(FromPrimitive, Show)] #[derive(FromPrimitive, Debug)]
#[repr(i32)] #[repr(i32)]
enum LibSslError { enum LibSslError {
ErrorNone = ffi::SSL_ERROR_NONE, ErrorNone = ffi::SSL_ERROR_NONE,
@ -426,7 +426,7 @@ pub struct SslStream<S> {
buf: Vec<u8> buf: Vec<u8>
} }
impl<S> fmt::Show for SslStream<S> where S: fmt::Show { impl<S> fmt::Debug for SslStream<S> where S: fmt::Debug {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "SslStream {{ stream: {:?}, ssl: {:?} }}", self.stream, self.ssl) write!(fmt, "SslStream {{ stream: {:?}, ssl: {:?} }}", self.stream, self.ssl)
} }
@ -510,7 +510,7 @@ impl<S: Stream> SslStream<S> {
LibSslError::ErrorWantRead => { LibSslError::ErrorWantRead => {
try_ssl_stream!(self.flush()); try_ssl_stream!(self.flush());
let len = try_ssl_stream!(self.stream.read(self.buf.as_mut_slice())); 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::ErrorWantWrite => { try_ssl_stream!(self.flush()) }
LibSslError::ErrorZeroReturn => return Err(SslSessionClosed), LibSslError::ErrorZeroReturn => return Err(SslSessionClosed),
@ -523,7 +523,7 @@ impl<S: Stream> SslStream<S> {
fn write_through(&mut self) -> IoResult<()> { fn write_through(&mut self) -> IoResult<()> {
loop { loop {
match self.ssl.get_wbio().read(self.buf.as_mut_slice()) { 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 None => break
}; };
} }
@ -587,7 +587,7 @@ impl<S: Stream> Writer for SslStream<S> {
} }
/// A utility type to help in cases where the use of SSL is decided at runtime. /// A utility type to help in cases where the use of SSL is decided at runtime.
#[derive(Show)] #[derive(Debug)]
pub enum MaybeSslStream<S> where S: Stream { pub enum MaybeSslStream<S> where S: Stream {
/// A connection using SSL /// A connection using SSL
Ssl(SslStream<S>), Ssl(SslStream<S>),