From 09745829f19975455d5a8551e34f1671873776b2 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 25 Feb 2020 23:31:21 +0100 Subject: [PATCH] client: Remove Result from Mechanism::initial(). --- sasl/src/client/mechanisms/plain.rs | 4 ++-- sasl/src/client/mechanisms/scram.rs | 8 ++++---- sasl/src/client/mod.rs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sasl/src/client/mechanisms/plain.rs b/sasl/src/client/mechanisms/plain.rs index 1c5bd1a3..08036e60 100644 --- a/sasl/src/client/mechanisms/plain.rs +++ b/sasl/src/client/mechanisms/plain.rs @@ -39,12 +39,12 @@ impl Mechanism for Plain { } } - fn initial(&mut self) -> Result, String> { + fn initial(&mut self) -> Vec { let mut auth = Vec::new(); auth.push(0); auth.extend(self.username.bytes()); auth.push(0); auth.extend(self.password.bytes()); - Ok(auth) + auth } } diff --git a/sasl/src/client/mechanisms/scram.rs b/sasl/src/client/mechanisms/scram.rs index a3bd35c9..f3c1d30a 100644 --- a/sasl/src/client/mechanisms/scram.rs +++ b/sasl/src/client/mechanisms/scram.rs @@ -93,7 +93,7 @@ impl Mechanism for Scram { } } - fn initial(&mut self) -> Result, String> { + fn initial(&mut self) -> Vec { let mut gs2_header = Vec::new(); gs2_header.extend(self.channel_binding.header()); let mut bare = Vec::new(); @@ -108,7 +108,7 @@ impl Mechanism for Scram { initial_message: bare, gs2_header: gs2_header, }; - Ok(data) + data } fn response(&mut self, challenge: &[u8]) -> Result, String> { @@ -206,7 +206,7 @@ mod tests { let server_final = b"v=rmF9pqV8S7suAoZWja4dJRkFsKQ="; let mut mechanism = Scram::::new_with_nonce(username, password, client_nonce.to_owned()); - let init = mechanism.initial().unwrap(); + let init = mechanism.initial(); assert_eq!( String::from_utf8(init.clone()).unwrap(), String::from_utf8(client_init[..].to_owned()).unwrap() @@ -231,7 +231,7 @@ mod tests { let server_final = b"v=6rriTRBi23WpRR/wtup+mMhUZUn/dB5nLTJRsjl95G4="; let mut mechanism = Scram::::new_with_nonce(username, password, client_nonce.to_owned()); - let init = mechanism.initial().unwrap(); + let init = mechanism.initial(); assert_eq!( String::from_utf8(init.clone()).unwrap(), String::from_utf8(client_init[..].to_owned()).unwrap() diff --git a/sasl/src/client/mod.rs b/sasl/src/client/mod.rs index 2acf9cff..93463f65 100644 --- a/sasl/src/client/mod.rs +++ b/sasl/src/client/mod.rs @@ -11,8 +11,8 @@ pub trait Mechanism { Self: Sized; /// Provides initial payload of the SASL mechanism. - fn initial(&mut self) -> Result, String> { - Ok(Vec::new()) + fn initial(&mut self) -> Vec { + Vec::new() } /// Creates a response to the SASL challenge.