Skip to main content

stellar_xdr/generated/
path_payment_strict_send_op.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// PathPaymentStrictSendOp is an XDR Struct defined as:
5///
6/// ```text
7/// struct PathPaymentStrictSendOp
8/// {
9///     Asset sendAsset;  // asset we pay with
10///     int64 sendAmount; // amount of sendAsset to send (excluding fees)
11///
12///     MuxedAccount destination; // recipient of the payment
13///     Asset destAsset;          // what they end up with
14///     int64 destMin;            // the minimum amount of dest asset to
15///                               // be received
16///                               // The operation will fail if it can't be met
17///
18///     Asset path<5>; // additional hops it must go through to get there
19/// };
20/// ```
21///
22#[cfg_attr(feature = "alloc", derive(Default))]
23#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
24#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
25#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
26#[cfg_attr(
27    all(feature = "serde", feature = "alloc"),
28    serde_with::serde_as,
29    derive(serde::Serialize, serde::Deserialize),
30    serde(rename_all = "snake_case")
31)]
32#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
33pub struct PathPaymentStrictSendOp {
34    pub send_asset: Asset,
35    #[cfg_attr(
36        all(feature = "serde", feature = "alloc"),
37        serde_as(as = "NumberOrString")
38    )]
39    pub send_amount: i64,
40    pub destination: MuxedAccount,
41    pub dest_asset: Asset,
42    #[cfg_attr(
43        all(feature = "serde", feature = "alloc"),
44        serde_as(as = "NumberOrString")
45    )]
46    pub dest_min: i64,
47    pub path: VecM<Asset, 5>,
48}
49
50impl ReadXdr for PathPaymentStrictSendOp {
51    #[cfg(feature = "std")]
52    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
53        r.with_limited_depth(|r| {
54            Ok(Self {
55                send_asset: Asset::read_xdr(r)?,
56                send_amount: i64::read_xdr(r)?,
57                destination: MuxedAccount::read_xdr(r)?,
58                dest_asset: Asset::read_xdr(r)?,
59                dest_min: i64::read_xdr(r)?,
60                path: VecM::<Asset, 5>::read_xdr(r)?,
61            })
62        })
63    }
64}
65
66impl WriteXdr for PathPaymentStrictSendOp {
67    #[cfg(feature = "std")]
68    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
69        w.with_limited_depth(|w| {
70            self.send_asset.write_xdr(w)?;
71            self.send_amount.write_xdr(w)?;
72            self.destination.write_xdr(w)?;
73            self.dest_asset.write_xdr(w)?;
74            self.dest_min.write_xdr(w)?;
75            self.path.write_xdr(w)?;
76            Ok(())
77        })
78    }
79}