[][src]Struct oauth_credentials::Token

pub struct Token<C = String, T = C> {
    pub client: Credentials<C>,
    pub token: Credentials<T>,
}

A set of OAuth client credentials and token/temporary credentials used for authorizing requests on behalf of a resource owner.

Fields

client: Credentials<C>

Client credentials.

token: Credentials<T>

Token/temporary credentials.

Implementations

impl<C: AsRef<str>, T: AsRef<str>> Token<C, T>[src]

pub fn new(client: Credentials<C>, token: Credentials<T>) -> Self[src]

Creates a new Token.

pub fn from_parts(
    client_identifier: C,
    client_secret: C,
    token: T,
    token_secret: T
) -> Self
[src]

Creates a new Token out of identifier and shared-secret strings.

pub fn client(&self) -> Credentials<&str>[src]

Returns the client credentials part.

pub fn token(&self) -> Credentials<&str>[src]

Returns the token credentials part.

pub fn as_ref(&self) -> Token<&str>[src]

Converts from &Token<C, T> to Token<&str, &str>.

impl<C, T> Token<C, T>[src]

pub fn map_client<C2, F>(self, f: F) -> Token<C2, T> where
    F: FnMut(C) -> C2,
    C2: AsRef<str>, 
[src]

Maps a Token<C, T> to Token<C2, T> by applying a function to a contained client value, leaving a token value untouched.

Example

async fn get_token<C: AsRef<str>, T: AsRef<str>>(temporary: Token<C, T>) -> Token<C, String> {
    // ...
}
let token: Token<&str, String> = get_token(temporary.as_ref()).await;
let owned: Token = token.map_client(String::from);

pub fn map_token<T2, F>(self, f: F) -> Token<C, T2> where
    F: FnMut(T) -> T2,
    T2: AsRef<str>, 
[src]

Maps a Token<C, T> to Token<C, T2> by applying a function to a contained token value, leaving a client value untouched.

Example

async fn get_token<C: AsRef<str>, T: AsRef<str>>(temporary: Token<C, T>) -> Token<C, String> {
    // ...
}
let token: Token<Box<str>, String> = get_token(temporary).await;
let boxed: Token<Box<str>> = token.map_token(Into::into);

impl<T> Token<T>[src]

pub fn map<U, F>(self, mut f: F) -> Token<U> where
    F: FnMut(T) -> U,
    U: AsRef<str>, 
[src]

Maps a Token<T, T> to Token<U, U> by applying a function to contained string values.

Example

async fn get_token() -> Token {
    // ...
}
let token: Token = get_token().await;
let boxed: Token<Box<str>> = token.map(Into::into);

impl<'a, 'b> Token<&'a str, &'b str>[src]

pub fn from_ref<C: AsRef<str>, T: AsRef<str>>(
    client: &'a Credentials<C>,
    token: &'b Credentials<T>
) -> Self
[src]

Creates a new Token<&str, &str> from a pair of &Credentials<_>.

Trait Implementations

impl<C: Clone, T: Clone> Clone for Token<C, T>[src]

impl<C: Copy, T: Copy> Copy for Token<C, T>[src]

impl<C: Debug, T: Debug> Debug for Token<C, T>[src]

impl<'a, C: AsRef<str>, T: AsRef<str>> From<&'a Token<C, T>> for Token<&'a str>[src]

Auto Trait Implementations

impl<C, T> RefUnwindSafe for Token<C, T> where
    C: RefUnwindSafe,
    T: RefUnwindSafe
[src]

impl<C, T> Send for Token<C, T> where
    C: Send,
    T: Send
[src]

impl<C, T> Sync for Token<C, T> where
    C: Sync,
    T: Sync
[src]

impl<C, T> Unpin for Token<C, T> where
    C: Unpin,
    T: Unpin
[src]

impl<C, T> UnwindSafe for Token<C, T> where
    C: UnwindSafe,
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.