fireblocks_sdk/models/
chain_descriptor.rs

1// Fireblocks API
2//
3// Fireblocks provides a suite of applications to manage digital asset operations and a complete development platform to build your business on the blockchain.  - Visit our website for more information: [Fireblocks Website](https://fireblocks.com) - Visit our developer docs: [Fireblocks DevPortal](https://developers.fireblocks.com)
4//
5// The version of the OpenAPI document: 1.8.0
6// Contact: developers@fireblocks.com
7// Generated by: https://openapi-generator.tech
8
9use {
10    crate::models,
11    serde::{Deserialize, Deserializer, Serialize, Serializer},
12};
13
14#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub enum ChainDescriptor {
16    Eth,
17    Sol,
18    Matic,
19    EthTest6,
20    SolTest,
21    Other(String),
22}
23
24impl<'de> Deserialize<'de> for ChainDescriptor {
25    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
26    where
27        D: Deserializer<'de>,
28    {
29        let s = String::deserialize(deserializer)?;
30        match s.as_str() {
31            "ETH" => Ok(ChainDescriptor::Eth),
32            "SOL" => Ok(ChainDescriptor::Sol),
33            "MATIC" => Ok(ChainDescriptor::Matic),
34            "ETH_TEST6" => Ok(ChainDescriptor::EthTest6),
35            "SOL_TEST" => Ok(ChainDescriptor::SolTest),
36            _ => Ok(ChainDescriptor::Other(s)),
37        }
38    }
39}
40
41impl Serialize for ChainDescriptor {
42    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
43    where
44        S: Serializer,
45    {
46        let s = match self {
47            ChainDescriptor::Eth => "ETH",
48            ChainDescriptor::Sol => "SOL",
49            ChainDescriptor::Matic => "MATIC",
50            ChainDescriptor::EthTest6 => "ETH_TEST6",
51            ChainDescriptor::SolTest => "SOL_TEST",
52            ChainDescriptor::Other(s) => s,
53        };
54        serializer.serialize_str(s)
55    }
56}
57
58impl std::fmt::Display for ChainDescriptor {
59    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
60        match self {
61            Self::Eth => write!(f, "ETH"),
62            Self::Sol => write!(f, "SOL"),
63            Self::Matic => write!(f, "MATIC"),
64            Self::EthTest6 => write!(f, "ETH_TEST6"),
65            Self::SolTest => write!(f, "SOL_TEST"),
66            Self::Other(s) => write!(f, "{}", s),
67        }
68    }
69}
70
71impl Default for ChainDescriptor {
72    fn default() -> ChainDescriptor {
73        Self::Eth
74    }
75}