Add token traits

This commit is contained in:
Curtis McEnroe 2015-12-21 21:40:38 -05:00
parent ac156bc7b4
commit bfc17a3020
2 changed files with 25 additions and 0 deletions

View File

@ -2,3 +2,5 @@ extern crate chrono;
extern crate hyper;
extern crate rustc_serialize;
extern crate url;
pub mod token;

23
src/token/mod.rs Normal file
View File

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