libfj 0.10.0

An unofficial collection of APIs used in FreeJam games and mods
Documentation

use crate::robocraft::{DEFAULT_TOKEN};

/// Token generator for authenticated API endpoints
pub trait ITokenProvider {
    /// Retrieve the token to use
    fn token(&self) -> Result<String, ()>;

    /// Authentication scheme; the word before the auth token
    fn scheme(&self) -> &'static str {
        "Web"
    }
}

/// Token provider which uses DEFAULT_TOKEN
pub struct DefaultTokenProvider {
}

impl ITokenProvider for DefaultTokenProvider {
    fn token(&self) -> Result<String, ()> {
        Ok(DEFAULT_TOKEN.to_string())
    }
}