Delegates no longer need to implement Clone.

This commit is contained in:
Glenn Griffin
2019-11-11 08:43:40 -08:00
parent 7446200421
commit fa121d41b2
3 changed files with 6 additions and 8 deletions

View File

@@ -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

View File

@@ -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<C>,
device_code: &str,
pi: PollInformation,
fd: FD,
fd: &FD,
) -> Result<Option<Token>, PollError> {
if pi.expires_at <= Utc::now() {
fd.expired(&pi.expires_at);

View File

@@ -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