client: Remove Result from Mechanism::initial().

Emmanuel Gil Peyrot created

Change summary

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(-)

Detailed changes

sasl/src/client/mechanisms/plain.rs 🔗

@@ -39,12 +39,12 @@ impl Mechanism for Plain {
         }
     }
 
-    fn initial(&mut self) -> Result<Vec<u8>, String> {
+    fn initial(&mut self) -> Vec<u8> {
         let mut auth = Vec::new();
         auth.push(0);
         auth.extend(self.username.bytes());
         auth.push(0);
         auth.extend(self.password.bytes());
-        Ok(auth)
+        auth
     }
 }

sasl/src/client/mechanisms/scram.rs 🔗

@@ -93,7 +93,7 @@ impl<S: ScramProvider> Mechanism for Scram<S> {
         }
     }
 
-    fn initial(&mut self) -> Result<Vec<u8>, String> {
+    fn initial(&mut self) -> Vec<u8> {
         let mut gs2_header = Vec::new();
         gs2_header.extend(self.channel_binding.header());
         let mut bare = Vec::new();
@@ -108,7 +108,7 @@ impl<S: ScramProvider> Mechanism for Scram<S> {
             initial_message: bare,
             gs2_header: gs2_header,
         };
-        Ok(data)
+        data
     }
 
     fn response(&mut self, challenge: &[u8]) -> Result<Vec<u8>, String> {
@@ -206,7 +206,7 @@ mod tests {
         let server_final = b"v=rmF9pqV8S7suAoZWja4dJRkFsKQ=";
         let mut mechanism =
             Scram::<Sha1>::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::<Sha256>::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()

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<Vec<u8>, String> {
-        Ok(Vec::new())
+    fn initial(&mut self) -> Vec<u8> {
+        Vec::new()
     }
 
     /// Creates a response to the SASL challenge.