commit 770e2c72c056015ffa9c6cdb792f2054d98e1c47 Author: Jonathan Strong Date: Thu Jan 23 16:13:56 2020 -0500 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46f3847 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +Cargo.lock +*.swp diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..708dc67 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "markets" +version = "0.1.0" +authors = ["Jonathan Strong "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde = { version = "1", features = ["derive"] } +chrono = { version = "0.4", features = ["serde"] } +chrono-tz = "0.4" +uuid = { version = "0.7.0", features = ["serde", "v4", "slog"] } +hashbrown = { version = "0.6.3", default_features = false, features = ["serde", "ahash"] } diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..289c7a1 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,52 @@ +use serde::{Serialize, Deserialize}; +use chrono_tz::Tz; +use chrono_tz::US::{Eastern, Central, Pacific}; +use chrono_tz::Etc::GMTPlus5; + +use Market::*; + +#[derive(Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)] +#[repr(u8)] +pub enum Market { + Pjm = 1, + Miso = 2, + Caiso = 3, + Ercot = 4, + Spp = 5, + Nyiso = 6, + Iso = 7, +} + +impl Market { + pub fn time_zone(&self) -> Tz { + match self { + Pjm => Eastern, + Miso => GMTPlus5, + Caiso => Pacific, + Ercot => Central, + Spp => Central, + Nyiso => Eastern, + Iso => Eastern, + } + } + + pub fn as_str(&self) -> &'static str { + match self { + Pjm => "pjm", + Miso => "miso", + Caiso => "caiso", + Ercot => "ercot", + Spp => "spp", + Nyiso => "nyiso", + Iso => "isone", + } + } +} + +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +}