roshi 0.0.1

A Rust client for the Kalshi API
Documentation
use std::str::FromStr;

use crate::constants::endpoints::{DEMO_HTTP_API_BASE, LIVE_HTTP_API_BASE};

#[derive(Debug, Clone, Copy)]
pub enum Mode {
    Demo,
    Live,
}

impl Mode {
    pub fn base_url(&self) -> &'static str {
        match self {
            Mode::Demo => DEMO_HTTP_API_BASE,
            Mode::Live => LIVE_HTTP_API_BASE,
        }
    }
}

impl Default for Mode {
    fn default() -> Self {
        Mode::Demo
    }
}

impl FromStr for Mode {
    type Err = &'static str;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s.to_lowercase().as_str() {
            "demo" => Ok(Mode::Demo),
            "live" => Ok(Mode::Live),
            _ => Err("Invalid mode. Use 'Demo' or 'Live'."),
        }
    }
}