hiero_sdk/
fee_estimate_types.rs1use std::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct FeeExtra {
8 pub name: Option<String>,
10
11 pub included: u64,
13
14 pub count: u64,
16
17 pub charged: u64,
19
20 pub fee_per_unit: u64,
22
23 pub subtotal: u64,
25}
26
27impl fmt::Display for FeeExtra {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 write!(
30 f,
31 "FeeExtra {{ name: {:?}, included: {}, count: {}, charged: {}, fee_per_unit: {}, subtotal: {} }}",
32 self.name, self.included, self.count, self.charged, self.fee_per_unit, self.subtotal
33 )
34 }
35}
36
37#[derive(Debug, Clone, PartialEq, Eq)]
39pub struct FeeEstimate {
40 pub base: u64,
42
43 pub extras: Vec<FeeExtra>,
45}
46
47impl FeeEstimate {
48 #[must_use]
50 pub fn subtotal(&self) -> u64 {
51 self.base + self.extras.iter().map(|e| e.subtotal).sum::<u64>()
52 }
53}
54
55impl fmt::Display for FeeEstimate {
56 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
57 write!(f, "FeeEstimate {{ base: {}, extras: {} }}", self.base, self.extras.len())
58 }
59}
60
61#[derive(Debug, Clone, PartialEq, Eq)]
63pub struct NetworkFee {
64 pub multiplier: u32,
66
67 pub subtotal: u64,
69}
70
71impl fmt::Display for NetworkFee {
72 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
73 write!(f, "NetworkFee {{ multiplier: {}, subtotal: {} }}", self.multiplier, self.subtotal)
74 }
75}
76
77#[derive(Debug, Clone, PartialEq, Eq)]
79pub struct FeeEstimateResponse {
80 pub high_volume_multiplier: u64,
82
83 pub network: Option<NetworkFee>,
85
86 pub node: Option<FeeEstimate>,
88
89 pub service: Option<FeeEstimate>,
91
92 pub total: u64,
94}
95
96impl fmt::Display for FeeEstimateResponse {
97 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
98 write!(f, "FeeEstimateResponse {{ total: {} }}", self.total)
99 }
100}