Add token traits
This commit is contained in:
parent
ac156bc7b4
commit
bfc17a3020
|
@ -2,3 +2,5 @@ extern crate chrono;
|
||||||
extern crate hyper;
|
extern crate hyper;
|
||||||
extern crate rustc_serialize;
|
extern crate rustc_serialize;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
|
||||||
|
pub mod token;
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
//! Tokens.
|
||||||
|
|
||||||
|
/// OAuth 2.0 tokens.
|
||||||
|
///
|
||||||
|
/// See [RFC6749, section 5](http://tools.ietf.org/html/rfc6749#section-5).
|
||||||
|
pub trait Token<L: Lifetime> {
|
||||||
|
/// Returns the access token.
|
||||||
|
///
|
||||||
|
/// See [RFC6749, section 1.4](http://tools.ietf.org/html/rfc6749#section-1.4).
|
||||||
|
fn access_token(&self) -> &str;
|
||||||
|
|
||||||
|
/// Returns the scope, if available.
|
||||||
|
fn scope(&self) -> Option<&str>;
|
||||||
|
|
||||||
|
/// Returns the token lifetime.
|
||||||
|
fn lifetime(&self) -> &L;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// OAuth 2.0 token lifetimes.
|
||||||
|
pub trait Lifetime {
|
||||||
|
/// Returns true if the token is no longer valid.
|
||||||
|
fn expired(&self) -> bool;
|
||||||
|
}
|
Loading…
Reference in New Issue