bybit_rust_api/rest/enums/
symbol.rs1use std::fmt::{Display, Formatter, Result};
2
3use serde::{Deserialize, Serialize};
4
5use crate::rest::enums::symbol_type::SymbolType;
6
7#[derive(Debug, Serialize, Deserialize, PartialEq)]
8pub struct Symbol {
9 pub symbol: String,
10 pub symbol_type: SymbolType,
11}
12
13impl Display for Symbol {
14 fn fmt(&self, f: &mut Formatter) -> Result {
15 write!(f, "{}", self.symbol)
16 }
17}
18
19impl Symbol {
20 pub fn new(symbol: String, symbol_type: SymbolType) -> Self {
21 Symbol {
22 symbol,
23 symbol_type,
24 }
25 }
26
27 pub fn is_type(&self, symbol_type: SymbolType) -> bool {
28 self.symbol_type == symbol_type
29 }
30 pub fn is_usdt_perpetual(&self) -> bool {
31 self.symbol_type == SymbolType::USDTPerpetual
32 }
33 pub fn is_usdc_perpetual(&self) -> bool {
34 self.symbol_type == SymbolType::USDCPerpetual
35 }
36 pub fn is_usdc_futures(&self) -> bool {
37 self.symbol_type == SymbolType::USDCFutures
38 }
39 pub fn is_inverse_perpetual(&self) -> bool {
40 self.symbol_type == SymbolType::InversePerpetual
41 }
42 pub fn is_inverse_futures(&self) -> bool {
43 self.symbol_type == SymbolType::InverseFutures
44 }
45 pub fn is_spot(&self) -> bool {
46 self.symbol_type == SymbolType::Spot
47 }
48}