Skip to content

Commit b370112

Browse files
committed
feat: Add optional serde support for RithmicEnv
Add serde feature flag that enables Serialize/Deserialize derives for RithmicEnv. Also adds Copy and Default traits to the enum.
1 parent 6dc0a15 commit b370112

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ categories = ["api-bindings", "finance"]
1212

1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

15+
[features]
16+
default = []
17+
serde = ["dep:serde"]
18+
1519
[dependencies]
20+
serde = { version = "1", features = ["derive"], optional = true }
1621
async-trait = "0.1.88"
1722
futures-util = "0.3.31"
1823
prost = "0.13.5"

src/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ use std::{env, fmt, str::FromStr};
2626
/// Trading environment selector.
2727
///
2828
/// Determines which Rithmic environment to connect to.
29-
#[derive(Clone, Debug, PartialEq, Eq)]
29+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
30+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
31+
#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
3032
pub enum RithmicEnv {
33+
#[default]
3134
Demo,
3235
Live,
3336
Test,

0 commit comments

Comments
 (0)