use crate::{Backend, Steam};
pub trait Auth: Sized {
fn auth(&self) -> Option<(&str, String)>;
fn with_client<B: Backend>(self, client: B) -> Steam<Self, B> {
Steam::with_auth_and_client(self, client)
}
}
#[derive(Clone, Debug)]
pub struct ApiKey {
pub key: String,
}
impl ApiKey {
pub fn new(key: impl AsRef<str>) -> Self {
let key = key.as_ref().to_string();
Self { key }
}
}
impl Auth for ApiKey {
fn auth(&self) -> Option<(&str, String)> {
Some(("key", self.key.to_string()))
}
}
#[derive(Clone, Debug, Default)]
pub struct Unauthorize;
impl Auth for Unauthorize {
fn auth(&self) -> Option<(&str, String)> {
None
}
}