cipherstash-client 0.34.1-alpha.1

The official CipherStash SDK
Documentation
use crate::credentials::{ClearTokenError, Credentials, GetTokenError};
use async_trait::async_trait;

pub struct StaticCredentials<T: Clone> {
    token: T,
}

impl<T: Clone> StaticCredentials<T> {
    pub fn new(token: T) -> Self {
        Self { token }
    }
}

#[async_trait]
impl<T: Clone + Send + Sync + 'static> Credentials for StaticCredentials<T> {
    type Token = T;

    async fn get_token(&self) -> Result<Self::Token, GetTokenError> {
        // FIXME: The trait design forces this clone
        Ok(self.token.clone())
    }

    async fn clear_token(&self) -> Result<(), ClearTokenError> {
        Ok(())
    }
}