1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! <https://xrpl.org/account_lines.html>
use crate::{
Request, RequestPagination, ResponsePagination, RetrieveLedgerSpec, ReturnLedgerSpec,
WithLedgerSpec, WithRequestPagination, WithResponsePagination,
};
use serde::{Deserialize, Serialize};
#[derive(Default, Debug, Clone, Serialize)]
pub struct AccountLinesRequest {
pub account: String,
/// The Address of a second account. If provided, show only lines of trust
/// connecting the two accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub peer: Option<String>,
#[serde(flatten)]
pub ledger_spec: RetrieveLedgerSpec,
#[serde(flatten)]
pub pagination: RequestPagination,
}
impl Request for AccountLinesRequest {
type Response = AccountLinesResponse;
fn method(&self) -> String {
"account_lines".to_owned()
}
}
impl WithLedgerSpec for AccountLinesRequest {
fn as_ledger_spec(&self) -> &crate::RetrieveLedgerSpec {
&self.ledger_spec
}
fn as_ledger_spec_mut(&mut self) -> &mut crate::RetrieveLedgerSpec {
&mut self.ledger_spec
}
}
impl WithRequestPagination for AccountLinesRequest {
fn as_pagination(&self) -> &RequestPagination {
&self.pagination
}
fn as_pagination_mut(&mut self) -> &mut RequestPagination {
&mut self.pagination
}
}
impl AccountLinesRequest {
pub fn new(account: &str) -> Self {
Self {
account: account.to_owned(),
..Default::default()
}
}
pub fn peer(self, peer: &str) -> Self {
Self {
peer: Some(peer.to_owned()),
..self
}
}
}
// #TODO consider extracting as a type.
#[derive(Debug, Serialize, Deserialize)]
pub struct AccountLine {
pub account: String,
pub balance: String,
pub currency: String,
pub limit: String,
pub limit_peer: String,
/// Rate at which the account values incoming balances on this trust line,
/// as a ratio of this value per 1 billion units. (For example, a value of
/// 500 million represents a 0.5:1 ratio.) As a special case, 0 is treated
/// as a 1:1 ratio.
pub quality_in: u64,
/// Rate at which the account values outgoing balances on this trust line, as a ratio of this value per 1 billion
/// units. (For example, a value of 500 million represents a 0.5:1 ratio.)
/// As a special case, 0 is treated as a 1:1 ratio.
pub quality_out: u64,
/// If true, this account has enabled the No Ripple flag for this trust line.
/// If present and false, this account has disabled the No Ripple flag, but,
/// because the account also has the Default Ripple flag disabled, that is
/// not considered the default state. If omitted, the account has the
/// No Ripple flag disabled for this trust line and Default Ripple enabled.
pub no_ripple: Option<bool>,
/// If true, the peer account has enabled the No Ripple flag for this trust
/// line. If present and false, this account has disabled the No Ripple
/// flag, but, because the account also has the Default Ripple flag
/// disabled, that is not considered the default state. If omitted,
/// the account has the No Ripple flag disabled for this trust line and
/// Default Ripple enabled..
pub no_ripple_peer: Option<bool>,
/// If true, this account has authorized this trust line. The default is false.
pub authorized: Option<bool>,
/// If true, the peer account has authorized this trust line. The default is
/// false.
pub peer_authorized: Option<bool>,
/// If true, this account has frozen this trust line. The default is false.
pub freeze: Option<bool>,
/// If true, the peer account has frozen this trust line. The default is false.
pub freeze_peer: Option<bool>,
}
#[derive(Debug, Deserialize)]
pub struct AccountLinesResponse {
pub lines: Vec<AccountLine>,
#[serde(flatten)]
pub ledger_spec: ReturnLedgerSpec,
#[serde(flatten)]
pub pagination: ResponsePagination,
}
impl WithResponsePagination for AccountLinesResponse {
fn as_pagination(&self) -> &ResponsePagination {
&self.pagination
}
}