Skip to content

Commit 565ac02

Browse files
committed
feat: from_str_const InstrumentType
1 parent 1d94f23 commit 565ac02

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pragma-common"
3-
version = "0.3.22"
3+
version = "0.3.23"
44
edition = "2021"
55
rust-version = "1.81"
66
categories = ["finance", "api-bindings"]

src/instrument_type.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ impl InstrumentType {
4242
Self::Perp => true,
4343
}
4444
}
45+
46+
pub const fn from_str_const(s: &str) -> Option<Self> {
47+
match s.as_bytes() {
48+
b"spot" | b"SPOT" | b"Spot" => Some(Self::Spot),
49+
b"perp" | b"PERP" | b"Perp" => Some(Self::Perp),
50+
_ => None,
51+
}
52+
}
4553
}
4654

4755
impl Display for InstrumentType {

0 commit comments

Comments
 (0)