From 9e9f09a9a531bb47a559fe2a38e55544a0861a74 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 17 Jan 2019 22:54:32 +0100 Subject: [PATCH] Update to Edition 2018. --- sasl/Cargo.toml | 1 + sasl/src/client/mechanisms/anonymous.rs | 4 ++-- sasl/src/client/mechanisms/plain.rs | 4 ++-- sasl/src/client/mechanisms/scram.rs | 14 +++++++------- sasl/src/client/mod.rs | 2 +- sasl/src/common/scram.rs | 4 ++-- sasl/src/lib.rs | 7 +------ sasl/src/secret.rs | 8 ++++---- sasl/src/server/mechanisms/plain.rs | 6 +++--- sasl/src/server/mechanisms/scram.rs | 10 +++++----- sasl/src/server/mod.rs | 4 ++-- 11 files changed, 30 insertions(+), 34 deletions(-) diff --git a/sasl/Cargo.toml b/sasl/Cargo.toml index af0f340e..225e9f7d 100644 --- a/sasl/Cargo.toml +++ b/sasl/Cargo.toml @@ -9,6 +9,7 @@ documentation = "https://docs.rs/sasl" readme = "README.md" keywords = ["sasl", "authentication"] license = "LGPL-3.0+" +edition = "2018" [badges] gitlab = { repository = "lumi/sasl-rs" } diff --git a/sasl/src/client/mechanisms/anonymous.rs b/sasl/src/client/mechanisms/anonymous.rs index d95245a8..45361377 100644 --- a/sasl/src/client/mechanisms/anonymous.rs +++ b/sasl/src/client/mechanisms/anonymous.rs @@ -1,7 +1,7 @@ //! Provides the SASL "ANONYMOUS" mechanism. -use client::Mechanism; -use common::{Credentials, Secret}; +use crate::client::Mechanism; +use crate::common::{Credentials, Secret}; /// A struct for the SASL ANONYMOUS mechanism. pub struct Anonymous; diff --git a/sasl/src/client/mechanisms/plain.rs b/sasl/src/client/mechanisms/plain.rs index 786978da..1c5bd1a3 100644 --- a/sasl/src/client/mechanisms/plain.rs +++ b/sasl/src/client/mechanisms/plain.rs @@ -1,7 +1,7 @@ //! Provides the SASL "PLAIN" mechanism. -use client::Mechanism; -use common::{Credentials, Identity, Password, Secret}; +use crate::client::Mechanism; +use crate::common::{Credentials, Identity, Password, Secret}; /// A struct for the SASL PLAIN mechanism. pub struct Plain { diff --git a/sasl/src/client/mechanisms/scram.rs b/sasl/src/client/mechanisms/scram.rs index b19ed48c..abc5472a 100644 --- a/sasl/src/client/mechanisms/scram.rs +++ b/sasl/src/client/mechanisms/scram.rs @@ -2,11 +2,11 @@ use base64; -use client::Mechanism; -use common::scram::{generate_nonce, ScramProvider}; -use common::{parse_frame, xor, ChannelBinding, Credentials, Identity, Password, Secret}; +use crate::client::Mechanism; +use crate::common::scram::{generate_nonce, ScramProvider}; +use crate::common::{parse_frame, xor, ChannelBinding, Credentials, Identity, Password, Secret}; -use error::Error; +use crate::error::Error; use std::marker::PhantomData; @@ -189,9 +189,9 @@ impl Mechanism for Scram { #[cfg(test)] mod tests { - use client::mechanisms::Scram; - use client::Mechanism; - use common::scram::{Sha1, Sha256}; + use crate::client::mechanisms::Scram; + use crate::client::Mechanism; + use crate::common::scram::{Sha1, Sha256}; #[test] fn scram_sha1_works() { diff --git a/sasl/src/client/mod.rs b/sasl/src/client/mod.rs index d8655d54..2acf9cff 100644 --- a/sasl/src/client/mod.rs +++ b/sasl/src/client/mod.rs @@ -1,4 +1,4 @@ -use common::Credentials; +use crate::common::Credentials; /// A trait which defines SASL mechanisms. pub trait Mechanism { diff --git a/sasl/src/common/scram.rs b/sasl/src/common/scram.rs index 6833a899..2ccba1fc 100644 --- a/sasl/src/common/scram.rs +++ b/sasl/src/common/scram.rs @@ -6,9 +6,9 @@ use openssl::pkey::PKey; use openssl::rand::rand_bytes; use openssl::sign::Signer; -use common::Password; +use crate::common::Password; -use secret; +use crate::secret; use base64; diff --git a/sasl/src/lib.rs b/sasl/src/lib.rs index 9e137971..2a64e762 100644 --- a/sasl/src/lib.rs +++ b/sasl/src/lib.rs @@ -163,11 +163,6 @@ //! sasl = "*" //! ``` -extern crate base64; - -#[cfg(feature = "scram")] -extern crate openssl; - mod error; pub mod client; @@ -176,4 +171,4 @@ pub mod server; pub mod common; pub mod secret; -pub use error::Error; +pub use crate::error::Error; diff --git a/sasl/src/secret.rs b/sasl/src/secret.rs index 54c94c84..690bf36d 100644 --- a/sasl/src/secret.rs +++ b/sasl/src/secret.rs @@ -21,8 +21,8 @@ pub struct Pbkdf2Sha1 { impl Pbkdf2Sha1 { #[cfg(feature = "openssl")] pub fn derive(password: &str, salt: &[u8], iterations: usize) -> Result { - use common::scram::{ScramProvider, Sha1}; - use common::Password; + use crate::common::scram::{ScramProvider, Sha1}; + use crate::common::Password; let digest = Sha1::derive(&Password::Plain(password.to_owned()), salt, iterations)?; Ok(Pbkdf2Sha1 { salt: salt.to_vec(), @@ -56,8 +56,8 @@ pub struct Pbkdf2Sha256 { impl Pbkdf2Sha256 { #[cfg(feature = "openssl")] pub fn derive(password: &str, salt: &[u8], iterations: usize) -> Result { - use common::scram::{ScramProvider, Sha256}; - use common::Password; + use crate::common::scram::{ScramProvider, Sha256}; + use crate::common::Password; let digest = Sha256::derive(&Password::Plain(password.to_owned()), salt, iterations)?; Ok(Pbkdf2Sha256 { salt: salt.to_vec(), diff --git a/sasl/src/server/mechanisms/plain.rs b/sasl/src/server/mechanisms/plain.rs index 1deebbe5..8df0e76f 100644 --- a/sasl/src/server/mechanisms/plain.rs +++ b/sasl/src/server/mechanisms/plain.rs @@ -1,6 +1,6 @@ -use common::Identity; -use secret; -use server::{Mechanism, Response, Validator}; +use crate::common::Identity; +use crate::secret; +use crate::server::{Mechanism, Response, Validator}; pub struct Plain> { validator: V, diff --git a/sasl/src/server/mechanisms/scram.rs b/sasl/src/server/mechanisms/scram.rs index 5f6feaec..ad027686 100644 --- a/sasl/src/server/mechanisms/scram.rs +++ b/sasl/src/server/mechanisms/scram.rs @@ -2,11 +2,11 @@ use std::marker::PhantomData; use base64; -use common::scram::{generate_nonce, ScramProvider}; -use common::{parse_frame, xor, ChannelBinding, Identity}; -use secret; -use secret::Pbkdf2Secret; -use server::{Mechanism, Provider, Response}; +use crate::common::scram::{generate_nonce, ScramProvider}; +use crate::common::{parse_frame, xor, ChannelBinding, Identity}; +use crate::secret; +use crate::secret::Pbkdf2Secret; +use crate::server::{Mechanism, Provider, Response}; enum ScramState { Init, diff --git a/sasl/src/server/mod.rs b/sasl/src/server/mod.rs index 87b4b07b..020e88b2 100644 --- a/sasl/src/server/mod.rs +++ b/sasl/src/server/mod.rs @@ -1,5 +1,5 @@ -use common::Identity; -use secret::Secret; +use crate::common::Identity; +use crate::secret::Secret; #[macro_export] macro_rules! impl_validator_using_provider {