From 03923d488578e3474f0c1b3a1377b576c0bf73be 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 4be4d876..6c5c7de0 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::{Secret, Credentials}; +use crate::client::Mechanism; +use crate::common::{Secret, Credentials}; /// 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 d4eeadfa..213fb785 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::{Secret, Credentials, Password, Identity}; +use crate::client::Mechanism; +use crate::common::{Secret, Credentials, Password, Identity}; /// 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 0c1ef3fd..fb2d6964 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::{ChannelBinding, parse_frame, xor, Password, Credentials, Secret, Identity}; -use common::scram::{ScramProvider, generate_nonce}; +use crate::client::Mechanism; +use crate::common::{ChannelBinding, parse_frame, xor, Password, Credentials, Secret, Identity}; +use crate::common::scram::{ScramProvider, generate_nonce}; -use error::Error; +use crate::error::Error; use std::marker::PhantomData; @@ -168,9 +168,9 @@ impl Mechanism for Scram { #[cfg(test)] mod tests { - use client::Mechanism; - use client::mechanisms::Scram; - use common::scram::{Sha1, Sha256}; + use crate::client::Mechanism; + use crate::client::mechanisms::Scram; + use crate::common::scram::{Sha1, Sha256}; #[test] fn scram_sha1_works() { // Source: https://wiki.xmpp.org/web/SASLandSCRAM-SHA-1 diff --git a/sasl/src/client/mod.rs b/sasl/src/client/mod.rs index 6e69e479..a6cd093e 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 f9bae91d..94d8bd62 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::error::ErrorStack; -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 87ce9769..4aa8265f 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; @@ -175,4 +170,4 @@ pub mod client; 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 dc6c1121..eb915c40 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(), @@ -50,8 +50,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 95b16b57..48d6a699 100644 --- a/sasl/src/server/mechanisms/plain.rs +++ b/sasl/src/server/mechanisms/plain.rs @@ -1,6 +1,6 @@ -use server::{Validator, Response, Mechanism}; -use common::Identity; -use secret; +use crate::server::{Validator, Response, Mechanism}; +use crate::common::Identity; +use crate::secret; pub struct Plain> { validator: V, diff --git a/sasl/src/server/mechanisms/scram.rs b/sasl/src/server/mechanisms/scram.rs index f6c8f8ea..a595d383 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 server::{Provider, Response, Mechanism}; -use common::{Identity, ChannelBinding, parse_frame, xor}; -use common::scram::{ScramProvider, generate_nonce}; -use secret; -use secret::Pbkdf2Secret; +use crate::server::{Provider, Response, Mechanism}; +use crate::common::{Identity, ChannelBinding, parse_frame, xor}; +use crate::common::scram::{ScramProvider, generate_nonce}; +use crate::secret; +use crate::secret::Pbkdf2Secret; enum ScramState { Init, diff --git a/sasl/src/server/mod.rs b/sasl/src/server/mod.rs index 926ed982..68fff983 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 {