Skip to main content

stellar_xdr/generated/
soroban_authorization_entries.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// SorobanAuthorizationEntries is an XDR Typedef defined as:
5///
6/// ```text
7/// typedef SorobanAuthorizationEntry SorobanAuthorizationEntries<>;
8/// ```
9///
10#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
11#[derive(Default, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
12#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
13#[cfg_attr(
14    all(feature = "serde", feature = "alloc"),
15    serde_with::serde_as,
16    derive(serde::Serialize, serde::Deserialize),
17    serde(rename_all = "snake_case")
18)]
19#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
20#[derive(Debug)]
21pub struct SorobanAuthorizationEntries(pub VecM<SorobanAuthorizationEntry>);
22
23impl From<SorobanAuthorizationEntries> for VecM<SorobanAuthorizationEntry> {
24    #[must_use]
25    fn from(x: SorobanAuthorizationEntries) -> Self {
26        x.0
27    }
28}
29
30impl From<VecM<SorobanAuthorizationEntry>> for SorobanAuthorizationEntries {
31    #[must_use]
32    fn from(x: VecM<SorobanAuthorizationEntry>) -> Self {
33        SorobanAuthorizationEntries(x)
34    }
35}
36
37impl AsRef<VecM<SorobanAuthorizationEntry>> for SorobanAuthorizationEntries {
38    #[must_use]
39    fn as_ref(&self) -> &VecM<SorobanAuthorizationEntry> {
40        &self.0
41    }
42}
43
44impl ReadXdr for SorobanAuthorizationEntries {
45    #[cfg(feature = "std")]
46    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
47        r.with_limited_depth(|r| {
48            let i = VecM::<SorobanAuthorizationEntry>::read_xdr(r)?;
49            let v = SorobanAuthorizationEntries(i);
50            Ok(v)
51        })
52    }
53}
54
55impl WriteXdr for SorobanAuthorizationEntries {
56    #[cfg(feature = "std")]
57    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
58        w.with_limited_depth(|w| self.0.write_xdr(w))
59    }
60}
61
62impl Deref for SorobanAuthorizationEntries {
63    type Target = VecM<SorobanAuthorizationEntry>;
64    fn deref(&self) -> &Self::Target {
65        &self.0
66    }
67}
68
69impl From<SorobanAuthorizationEntries> for Vec<SorobanAuthorizationEntry> {
70    #[must_use]
71    fn from(x: SorobanAuthorizationEntries) -> Self {
72        x.0 .0
73    }
74}
75
76impl TryFrom<Vec<SorobanAuthorizationEntry>> for SorobanAuthorizationEntries {
77    type Error = Error;
78    fn try_from(x: Vec<SorobanAuthorizationEntry>) -> Result<Self, Error> {
79        Ok(SorobanAuthorizationEntries(x.try_into()?))
80    }
81}
82
83#[cfg(feature = "alloc")]
84impl TryFrom<&Vec<SorobanAuthorizationEntry>> for SorobanAuthorizationEntries {
85    type Error = Error;
86    fn try_from(x: &Vec<SorobanAuthorizationEntry>) -> Result<Self, Error> {
87        Ok(SorobanAuthorizationEntries(x.try_into()?))
88    }
89}
90
91impl AsRef<Vec<SorobanAuthorizationEntry>> for SorobanAuthorizationEntries {
92    #[must_use]
93    fn as_ref(&self) -> &Vec<SorobanAuthorizationEntry> {
94        &self.0 .0
95    }
96}
97
98impl AsRef<[SorobanAuthorizationEntry]> for SorobanAuthorizationEntries {
99    #[cfg(feature = "alloc")]
100    #[must_use]
101    fn as_ref(&self) -> &[SorobanAuthorizationEntry] {
102        &self.0 .0
103    }
104    #[cfg(not(feature = "alloc"))]
105    #[must_use]
106    fn as_ref(&self) -> &[SorobanAuthorizationEntry] {
107        self.0 .0
108    }
109}