diff --git a/src/bn/mod.rs b/src/bn/mod.rs index bcf6c104..0bc79a8f 100644 --- a/src/bn/mod.rs +++ b/src/bn/mod.rs @@ -1,13 +1,14 @@ use libc::{c_int, c_ulong, c_void}; -use std::{fmt, ptr}; use std::c_str::CString; +use std::cmp::Ordering; +use std::{fmt, ptr}; use ffi; use ssl::error::SslError; pub struct BigNum(*mut ffi::BIGNUM); -#[deriving(Copy)] +#[derive(Copy)] #[repr(C)] pub enum RNGProperty { MsbMaybeZero = -1, @@ -303,11 +304,11 @@ impl BigNum { unsafe { let res = ffi::BN_ucmp(self.raw(), oth.raw()) as i32; if res < 0 { - Less + Ordering::Less } else if res > 0 { - Greater + Ordering::Greater } else { - Equal + Ordering::Equal } } } @@ -382,11 +383,11 @@ impl PartialOrd for BigNum { let v = ffi::BN_cmp(self.raw(), oth.raw()); let ret = if v == 0 { - Equal + Ordering::Equal } else if v < 0 { - Less + Ordering::Less } else { - Greater + Ordering::Greater }; Some(ret) } @@ -404,6 +405,7 @@ impl Drop for BigNum { } pub mod unchecked { + use std::ops::{Add, Div, Mul, Neg, Rem, Shl, Shr, Sub}; use ffi; use super::{BigNum}; diff --git a/src/crypto/hash.rs b/src/crypto/hash.rs index 2a181526..a9711e92 100644 --- a/src/crypto/hash.rs +++ b/src/crypto/hash.rs @@ -4,7 +4,7 @@ use std::io; use ffi; -#[deriving(Copy)] +#[derive(Copy)] pub enum HashType { MD5, SHA1, diff --git a/src/crypto/hmac.rs b/src/crypto/hmac.rs index 9e8b6361..03e59c6f 100644 --- a/src/crypto/hmac.rs +++ b/src/crypto/hmac.rs @@ -72,7 +72,7 @@ impl Drop for HMAC { #[cfg(test)] mod tests { use serialize::hex::FromHex; - use crypto::hash::HashType::{mod, MD5, SHA1, SHA224, SHA256, SHA384, SHA512}; + use crypto::hash::HashType::{self, MD5, SHA1, SHA224, SHA256, SHA384, SHA512}; use super::HMAC; #[test] diff --git a/src/crypto/pkey.rs b/src/crypto/pkey.rs index bab7addc..ac3a407e 100644 --- a/src/crypto/pkey.rs +++ b/src/crypto/pkey.rs @@ -6,7 +6,7 @@ use crypto::hash::HashType; use ffi; use ssl::error::{SslError, StreamError}; -#[deriving(Copy)] +#[derive(Copy)] enum Parts { Neither, Public, @@ -14,7 +14,7 @@ enum Parts { } /// Represents a role an asymmetric key might be appropriate for. -#[deriving(Copy)] +#[derive(Copy)] pub enum Role { Encrypt, Decrypt, @@ -23,7 +23,7 @@ pub enum Role { } /// Type of encryption padding to use. -#[deriving(Copy)] +#[derive(Copy)] pub enum EncryptionPadding { OAEP, PKCS1v15 diff --git a/src/crypto/symm.rs b/src/crypto/symm.rs index 61365f2e..d1021b37 100644 --- a/src/crypto/symm.rs +++ b/src/crypto/symm.rs @@ -2,14 +2,14 @@ use libc::{c_int}; use ffi; -#[deriving(Copy)] +#[derive(Copy)] pub enum Mode { Encrypt, Decrypt, } #[allow(non_camel_case_types)] -#[deriving(Copy)] +#[derive(Copy)] pub enum Type { AES_128_ECB, AES_128_CBC, diff --git a/src/ssl/error.rs b/src/ssl/error.rs index 7e8daef1..888a9cdc 100644 --- a/src/ssl/error.rs +++ b/src/ssl/error.rs @@ -9,7 +9,7 @@ use std::c_str::CString; use ffi; /// An SSL error -#[deriving(Show, Clone, PartialEq, Eq)] +#[derive(Show, Clone, PartialEq, Eq)] pub enum SslError { /// The underlying stream reported an error StreamError(IoError), @@ -37,7 +37,7 @@ impl error::Error for SslError { } /// An error from the OpenSSL library -#[deriving(Show, Clone, PartialEq, Eq)] +#[derive(Show, Clone, PartialEq, Eq)] pub enum OpensslError { /// An unknown error UnknownError { diff --git a/src/ssl/mod.rs b/src/ssl/mod.rs index 1bd36147..3a19f643 100644 --- a/src/ssl/mod.rs +++ b/src/ssl/mod.rs @@ -1,6 +1,8 @@ use libc::{c_int, c_void, c_long}; +use std::c_str::ToCStr; use std::io::{IoResult, IoError, EndOfFile, Stream, Reader, Writer}; use std::mem; +use std::num::FromPrimitive; use std::ptr; use std::sync::{Once, ONCE_INIT, Arc}; @@ -31,9 +33,9 @@ fn init() { } /// Determines the SSL method supported -#[deriving(Show, Hash, PartialEq, Eq)] +#[derive(Show, Hash, PartialEq, Eq)] #[allow(non_camel_case_types)] -#[deriving(Copy)] +#[derive(Copy)] pub enum SslMethod { #[cfg(feature = "sslv2")] /// Only support the SSLv2 protocol, requires `feature="sslv2"` @@ -69,7 +71,7 @@ impl SslMethod { } /// Determines the type of certificate verification used -#[deriving(Copy)] +#[derive(Copy)] #[repr(i32)] pub enum SslVerifyMode { /// Verify that the server's certificate is trusted @@ -389,7 +391,7 @@ impl Ssl { } -#[deriving(FromPrimitive, Show)] +#[derive(FromPrimitive, Show)] #[repr(i32)] enum LibSslError { ErrorNone = ffi::SSL_ERROR_NONE, @@ -404,7 +406,7 @@ enum LibSslError { } /// A stream wrapper which handles SSL encryption for an underlying stream. -#[deriving(Clone)] +#[derive(Clone)] pub struct SslStream { stream: S, ssl: Arc, diff --git a/src/x509/mod.rs b/src/x509/mod.rs index c82eab11..ed8fb77d 100644 --- a/src/x509/mod.rs +++ b/src/x509/mod.rs @@ -1,4 +1,6 @@ use libc::{c_int, c_long, c_uint}; +use std::c_str::ToCStr; +use std::cmp::Ordering; use std::mem; use std::num::SignedInt; use std::ptr; @@ -15,7 +17,7 @@ use ssl::error::{SslError, StreamError}; #[cfg(test)] mod tests; -#[deriving(Copy)] +#[derive(Copy)] #[repr(i32)] pub enum X509FileType { PEM = ffi::X509_FILETYPE_PEM, @@ -56,7 +58,7 @@ trait AsStr<'a> { fn as_str(&self) -> &'a str; } -#[deriving(Clone, Copy)] +#[derive(Clone, Copy)] pub enum KeyUsage { DigitalSignature, NonRepudiation, @@ -86,7 +88,7 @@ impl AsStr<'static> for KeyUsage { } -#[deriving(Clone, Copy)] +#[derive(Clone, Copy)] pub enum ExtKeyUsage { ServerAuth, ClientAuth, @@ -395,9 +397,9 @@ impl<'ctx> X509<'ctx> { _ => { let act_len = act_len as uint; match len.cmp(&act_len) { - Greater => None, - Equal => Some(v), - Less => panic!("Fingerprint buffer was corrupted!") + Ordering::Greater => None, + Ordering::Equal => Some(v), + Ordering::Less => panic!("Fingerprint buffer was corrupted!") } } } @@ -432,7 +434,7 @@ pub struct X509Name<'x> { macro_rules! make_validation_error( ($ok_val:ident, $($name:ident = $val:ident,)+) => ( - #[deriving(Copy)] + #[derive(Copy)] pub enum X509ValidationError { $($name,)+ X509UnknownError(c_int)