tesser_cli/
lib.rs

1pub mod alerts;
2pub mod app;
3pub mod data_validation;
4pub mod live;
5pub mod state;
6pub mod telemetry;
7
8pub use app::run as run_app;
9
10#[cfg(feature = "bybit")]
11pub use tesser_bybit::PublicChannel;
12
13#[cfg(not(feature = "bybit"))]
14pub use public_channel_stub::PublicChannel;
15
16#[cfg(not(feature = "bybit"))]
17mod public_channel_stub {
18    use std::str::FromStr;
19
20    use tesser_broker::BrokerError;
21
22    #[derive(Clone, Copy, Debug)]
23    pub enum PublicChannel {
24        Linear,
25        Inverse,
26        Spot,
27        Option,
28        Spread,
29    }
30
31    impl PublicChannel {
32        pub fn as_path(&self) -> &'static str {
33            match self {
34                Self::Linear => "linear",
35                Self::Inverse => "inverse",
36                Self::Spot => "spot",
37                Self::Option => "option",
38                Self::Spread => "spread",
39            }
40        }
41    }
42
43    impl FromStr for PublicChannel {
44        type Err = BrokerError;
45
46        fn from_str(value: &str) -> Result<Self, Self::Err> {
47            match value.to_lowercase().as_str() {
48                "linear" => Ok(Self::Linear),
49                "inverse" => Ok(Self::Inverse),
50                "spot" => Ok(Self::Spot),
51                "option" => Ok(Self::Option),
52                "spread" => Ok(Self::Spread),
53                other => Err(BrokerError::InvalidRequest(format!(
54                    "unsupported Bybit public channel '{other}'"
55                ))),
56            }
57        }
58    }
59}