stellar_xdr/curr/
ledgerkey.rs1use super::{
2 AccountEntry, ClaimableBalanceEntry, ConfigSettingEntry, ContractCodeEntry, ContractDataEntry,
3 DataEntry, LedgerEntry, LedgerEntryData, LedgerKey, LedgerKeyAccount,
4 LedgerKeyClaimableBalance, LedgerKeyConfigSetting, LedgerKeyContractCode,
5 LedgerKeyContractData, LedgerKeyData, LedgerKeyLiquidityPool, LedgerKeyOffer,
6 LedgerKeyTrustLine, LedgerKeyTtl, LiquidityPoolEntry, OfferEntry, TrustLineEntry, TtlEntry,
7};
8
9impl LedgerEntry {
10 #[must_use]
11 pub fn to_key(&self) -> LedgerKey {
12 self.data.to_key()
13 }
14}
15
16impl LedgerEntryData {
17 #[must_use]
18 pub fn to_key(&self) -> LedgerKey {
19 match &self {
20 LedgerEntryData::Ttl(e) => e.to_key().into(),
21 LedgerEntryData::Account(e) => e.to_key().into(),
22 LedgerEntryData::Trustline(e) => e.to_key().into(),
23 LedgerEntryData::Offer(e) => e.to_key().into(),
24 LedgerEntryData::Data(e) => e.to_key().into(),
25 LedgerEntryData::ClaimableBalance(e) => e.to_key().into(),
26 LedgerEntryData::LiquidityPool(e) => e.to_key().into(),
27 LedgerEntryData::ContractData(e) => e.to_key().into(),
28 LedgerEntryData::ContractCode(e) => e.to_key().into(),
29 LedgerEntryData::ConfigSetting(e) => e.to_key().into(),
30 }
31 }
32}
33
34impl TtlEntry {
35 #[must_use]
36 pub fn to_key(&self) -> LedgerKeyTtl {
37 LedgerKeyTtl {
38 key_hash: self.key_hash.clone(),
39 }
40 }
41}
42
43impl AccountEntry {
44 #[must_use]
45 pub fn to_key(&self) -> LedgerKeyAccount {
46 LedgerKeyAccount {
47 account_id: self.account_id.clone(),
48 }
49 }
50}
51
52impl TrustLineEntry {
53 #[must_use]
54 pub fn to_key(&self) -> LedgerKeyTrustLine {
55 LedgerKeyTrustLine {
56 account_id: self.account_id.clone(),
57 asset: self.asset.clone(),
58 }
59 }
60}
61
62impl OfferEntry {
63 #[must_use]
64 pub fn to_key(&self) -> LedgerKeyOffer {
65 LedgerKeyOffer {
66 seller_id: self.seller_id.clone(),
67 offer_id: self.offer_id,
68 }
69 }
70}
71
72impl DataEntry {
73 #[must_use]
74 pub fn to_key(&self) -> LedgerKeyData {
75 LedgerKeyData {
76 account_id: self.account_id.clone(),
77 data_name: self.data_name.clone(),
78 }
79 }
80}
81
82impl ClaimableBalanceEntry {
83 #[must_use]
84 pub fn to_key(&self) -> LedgerKeyClaimableBalance {
85 LedgerKeyClaimableBalance {
86 balance_id: self.balance_id.clone(),
87 }
88 }
89}
90
91impl LiquidityPoolEntry {
92 #[must_use]
93 pub fn to_key(&self) -> LedgerKeyLiquidityPool {
94 LedgerKeyLiquidityPool {
95 liquidity_pool_id: self.liquidity_pool_id.clone(),
96 }
97 }
98}
99
100impl ContractDataEntry {
101 #[must_use]
102 pub fn to_key(&self) -> LedgerKeyContractData {
103 LedgerKeyContractData {
104 contract: self.contract.clone(),
105 key: self.key.clone(),
106 durability: self.durability,
107 }
108 }
109}
110
111impl ContractCodeEntry {
112 #[must_use]
113 pub fn to_key(&self) -> LedgerKeyContractCode {
114 LedgerKeyContractCode {
115 hash: self.hash.clone(),
116 }
117 }
118}
119
120impl ConfigSettingEntry {
121 #[must_use]
122 pub fn to_key(&self) -> LedgerKeyConfigSetting {
123 LedgerKeyConfigSetting {
124 config_setting_id: self.discriminant(),
125 }
126 }
127}
128
129impl From<LedgerKeyTtl> for LedgerKey {
130 fn from(key: LedgerKeyTtl) -> Self {
131 LedgerKey::Ttl(key)
132 }
133}
134
135impl From<LedgerKeyAccount> for LedgerKey {
136 fn from(key: LedgerKeyAccount) -> Self {
137 LedgerKey::Account(key)
138 }
139}
140
141impl From<LedgerKeyTrustLine> for LedgerKey {
142 fn from(key: LedgerKeyTrustLine) -> Self {
143 LedgerKey::Trustline(key)
144 }
145}
146
147impl From<LedgerKeyOffer> for LedgerKey {
148 fn from(key: LedgerKeyOffer) -> Self {
149 LedgerKey::Offer(key)
150 }
151}
152
153impl From<LedgerKeyData> for LedgerKey {
154 fn from(key: LedgerKeyData) -> Self {
155 LedgerKey::Data(key)
156 }
157}
158
159impl From<LedgerKeyClaimableBalance> for LedgerKey {
160 fn from(key: LedgerKeyClaimableBalance) -> Self {
161 LedgerKey::ClaimableBalance(key)
162 }
163}
164
165impl From<LedgerKeyLiquidityPool> for LedgerKey {
166 fn from(key: LedgerKeyLiquidityPool) -> Self {
167 LedgerKey::LiquidityPool(key)
168 }
169}
170
171impl From<LedgerKeyContractData> for LedgerKey {
172 fn from(key: LedgerKeyContractData) -> Self {
173 LedgerKey::ContractData(key)
174 }
175}
176
177impl From<LedgerKeyContractCode> for LedgerKey {
178 fn from(key: LedgerKeyContractCode) -> Self {
179 LedgerKey::ContractCode(key)
180 }
181}
182
183impl From<LedgerKeyConfigSetting> for LedgerKey {
184 fn from(key: LedgerKeyConfigSetting) -> Self {
185 LedgerKey::ConfigSetting(key)
186 }
187}