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
use alloc::borrow::Cow;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use crate::models::{requests::RequestMethod, Model};
use super::{CommonFields, Request};
/// The tx method retrieves information on a single transaction.
///
/// See Tx:
/// `<https://xrpl.org/tx.html>`
#[skip_serializing_none]
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct Tx<'a> {
/// The common fields shared by all requests.
#[serde(flatten)]
pub common_fields: CommonFields<'a>,
/// If true, return transaction data and metadata as binary
/// serialized to hexadecimal strings. If false, return
/// transaction data and metadata as JSON. The default is false.
pub binary: Option<bool>,
/// Use this with min_ledger to specify a range of up to 1000
/// ledger indexes, ending with this ledger (inclusive). If the
/// server cannot find the transaction, it confirms whether it
/// was able to search all the ledgers in the requested range.
pub max_ledger: Option<u32>,
/// Use this with max_ledger to specify a range of up to 1000
/// ledger indexes, starting with this ledger (inclusive). If
/// the server cannot find the transaction, it confirms whether
/// it was able to search all the ledgers in this range.
pub min_ledger: Option<u32>,
/// The 256-bit hash of the transaction to look up, as hexadecimal.
pub transaction: Option<Cow<'a, str>>,
}
impl<'a> Model for Tx<'a> {}
impl<'a> Request<'a> for Tx<'a> {
fn get_common_fields(&self) -> &CommonFields<'a> {
&self.common_fields
}
fn get_common_fields_mut(&mut self) -> &mut CommonFields<'a> {
&mut self.common_fields
}
}
impl<'a> Tx<'a> {
pub fn new(
id: Option<Cow<'a, str>>,
binary: Option<bool>,
max_ledger: Option<u32>,
min_ledger: Option<u32>,
transaction: Option<Cow<'a, str>>,
) -> Self {
Self {
common_fields: CommonFields {
command: RequestMethod::Tx,
id,
},
binary,
min_ledger,
max_ledger,
transaction,
}
}
}