From fa121d41b2b1ff9862986b0bcbccf0e9e11a466f Mon Sep 17 00:00:00 2001 From: Glenn Griffin Date: Mon, 11 Nov 2019 08:43:40 -0800 Subject: [PATCH] Delegates no longer need to implement Clone. --- src/authenticator_delegate.rs | 4 ++-- src/device.rs | 6 +++--- src/lib.rs | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/authenticator_delegate.rs b/src/authenticator_delegate.rs index ad3b37c..f5bc4a9 100644 --- a/src/authenticator_delegate.rs +++ b/src/authenticator_delegate.rs @@ -71,7 +71,7 @@ impl Error for PollError { /// /// The only method that needs to be implemented manually is `present_user_code(...)`, /// as no assumptions are made on how this presentation should happen. -pub trait AuthenticatorDelegate: Clone + Send + Sync { +pub trait AuthenticatorDelegate: Send + Sync { /// Called whenever there is an client, usually if there are network problems. /// /// Return retry information. @@ -107,7 +107,7 @@ pub trait AuthenticatorDelegate: Clone + Send + Sync { /// FlowDelegate methods are called when an OAuth flow needs to ask the application what to do in /// certain cases. -pub trait FlowDelegate: Clone + Send + Sync { +pub trait FlowDelegate: Send + Sync { /// Called if the request code is expired. You will have to start over in this case. /// This will be the last call the delegate receives. /// Given `DateTime` is the expiration date diff --git a/src/device.rs b/src/device.rs index 8afc1f3..82e1aee 100644 --- a/src/device.rs +++ b/src/device.rs @@ -133,7 +133,7 @@ where let application_secret = &self.application_secret; let client = self.client.clone(); let wait = self.wait; - let fd = self.fd.clone(); + let fd = &self.fd; let (pollinf, device_code) = Self::request_code( application_secret, client.clone(), @@ -152,7 +152,7 @@ where client.clone(), &device_code, pollinf.clone(), - fd.clone(), + fd, ) .await; match r { @@ -270,7 +270,7 @@ where client: hyper::Client, device_code: &str, pi: PollInformation, - fd: FD, + fd: &FD, ) -> Result, PollError> { if pi.expires_at <= Utc::now() { fd.expired(&pi.expires_at); diff --git a/src/lib.rs b/src/lib.rs index 209874f..f53d54c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,13 +45,11 @@ //! use hyper::client::Client; //! use hyper_rustls::HttpsConnector; //! -//! use std::path::Path; -//! //! #[tokio::main] //! async fn main() { //! // Read application secret from a file. Sometimes it's easier to compile it directly into //! // the binary. The clientsecret file contains JSON like `{"installed":{"client_id": ... }}` -//! let secret = yup_oauth2::read_application_secret(Path::new("clientsecret.json")) +//! let secret = yup_oauth2::read_application_secret("clientsecret.json") //! .expect("clientsecret.json"); //! //! // Create an authenticator that uses an InstalledFlow to authenticate. The