Make provider pub so consumer can access it, and don't require all providers to be default

This commit is contained in:
Matthew Scheirer 2017-08-18 23:50:10 -04:00
parent f44a638568
commit f1390ce8a5
2 changed files with 7 additions and 4 deletions

View File

@ -27,11 +27,12 @@ pub struct Client<P: Provider> {
/// Redirect URI.
pub redirect_uri: Option<String>,
provider: P,
/// The provider.
pub provider: P,
}
impl<P: Provider> Client<P> {
/// Creates a client.
impl<P: Provider + Default> Client<P> {
/// Creates a client.
///
/// # Examples
///
@ -48,7 +49,9 @@ impl<P: Provider> Client<P> {
pub fn new(client_id: String, client_secret: String, redirect_uri: Option<String>) -> Self {
Client::with_provider(client_id, client_secret, P::default(), redirect_uri)
}
}
impl<P: Provider> Client<P> {
/// Creates a client with a given Provider. Use when the provider needs non-default Initialization.
pub fn with_provider(
client_id: String,

View File

@ -3,7 +3,7 @@
use token::{Token, Lifetime, Bearer, Static, Refresh};
/// OAuth 2.0 providers.
pub trait Provider: Default {
pub trait Provider {
/// The lifetime of tokens issued by the provider.
type Lifetime: Lifetime;