@@ -255,9 +255,9 @@ impl<T: Read + Write + Unpin + fmt::Debug + Send> Client<T> {
255
255
/// access_token: String,
256
256
/// }
257
257
///
258
- /// impl async_imap::Authenticator for OAuth2 {
258
+ /// impl async_imap::Authenticator for & OAuth2 {
259
259
/// type Response = String;
260
- /// fn process(&self, _: &[u8]) -> Self::Response {
260
+ /// fn process(&mut self, _: &[u8]) -> Self::Response {
261
261
/// format!(
262
262
/// "user={}\x01auth=Bearer {}\x01\x01",
263
263
/// self.user, self.access_token
@@ -292,7 +292,7 @@ impl<T: Read + Write + Unpin + fmt::Debug + Send> Client<T> {
292
292
pub async fn authenticate < A : Authenticator , S : AsRef < str > > (
293
293
mut self ,
294
294
auth_type : S ,
295
- authenticator : & A ,
295
+ authenticator : A ,
296
296
) -> :: std:: result:: Result < Session < T > , ( Error , Client < T > ) > {
297
297
let id = ok_or_unauth_client_err ! (
298
298
self . run_command( & format!( "AUTHENTICATE {}" , auth_type. as_ref( ) ) )
@@ -307,7 +307,7 @@ impl<T: Read + Write + Unpin + fmt::Debug + Send> Client<T> {
307
307
async fn do_auth_handshake < A : Authenticator > (
308
308
mut self ,
309
309
id : RequestId ,
310
- authenticator : & A ,
310
+ mut authenticator : A ,
311
311
) -> :: std:: result:: Result < Session < T > , ( Error , Client < T > ) > {
312
312
// explicit match blocks neccessary to convert error to tuple and not bind self too
313
313
// early (see also comment on `login`)
@@ -326,7 +326,7 @@ impl<T: Read + Write + Unpin + fmt::Debug + Send> Client<T> {
326
326
} else {
327
327
Vec :: new ( )
328
328
} ;
329
- let raw_response = & authenticator. process ( & challenge) ;
329
+ let raw_response = & mut authenticator. process ( & challenge) ;
330
330
let auth_response = base64:: encode ( raw_response) ;
331
331
332
332
ok_or_unauth_client_err ! (
@@ -1496,9 +1496,9 @@ mod tests {
1496
1496
enum Authenticate {
1497
1497
Auth ,
1498
1498
} ;
1499
- impl Authenticator for Authenticate {
1499
+ impl Authenticator for & Authenticate {
1500
1500
type Response = Vec < u8 > ;
1501
- fn process ( & self , challenge : & [ u8 ] ) -> Self :: Response {
1501
+ fn process ( & mut self , challenge : & [ u8 ] ) -> Self :: Response {
1502
1502
assert ! ( challenge == b"bar" , "Invalid authenticate challenge" ) ;
1503
1503
b"foo" . to_vec ( )
1504
1504
}
0 commit comments