Skip to content
Draft
491 changes: 490 additions & 1 deletion src/generated.rs

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions src/generated/account_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,65 @@ impl WriteXdr for AccountEntry {
})
}
}

/// AccountEntryView is a borrowing equivalent of [`AccountEntry`], usable in
/// const contexts and convertible to the owned type via [`From`]/[`Into`].
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct AccountEntryView<'a> {
pub account_id: AccountId,
pub balance: i64,
pub seq_num: SequenceNumber,
pub num_sub_entries: u32,
pub inflation_dest: Option<AccountId>,
pub flags: u32,
pub home_domain: String32View<'a>,
pub thresholds: Thresholds,
pub signers: VecMView<'a, SignerView<'a>, 20>,
pub ext: AccountEntryExtView<'a>,
}

#[cfg(feature = "alloc")]
impl From<&AccountEntryView<'_>> for AccountEntry {
#[must_use]
fn from(v: &AccountEntryView<'_>) -> Self {
Self {
account_id: v.account_id.clone(),
balance: v.balance,
seq_num: v.seq_num.clone(),
num_sub_entries: v.num_sub_entries,
inflation_dest: v.inflation_dest.clone(),
flags: v.flags,
home_domain: (&v.home_domain).into(),
thresholds: v.thresholds.clone(),
signers: v.signers.to_vecm_from(),
ext: (&v.ext).into(),
}
}
}

#[cfg(feature = "alloc")]
impl From<AccountEntryView<'_>> for AccountEntry {
#[must_use]
fn from(v: AccountEntryView<'_>) -> Self {
Self::from(&v)
}
}

impl WriteXdr for AccountEntryView<'_> {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.account_id.write_xdr(w)?;
self.balance.write_xdr(w)?;
self.seq_num.write_xdr(w)?;
self.num_sub_entries.write_xdr(w)?;
self.inflation_dest.write_xdr(w)?;
self.flags.write_xdr(w)?;
self.home_domain.write_xdr(w)?;
self.thresholds.write_xdr(w)?;
self.signers.write_xdr(w)?;
self.ext.write_xdr(w)?;
Ok(())
})
}
}
55 changes: 55 additions & 0 deletions src/generated/account_entry_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,58 @@ impl WriteXdr for AccountEntryExt {
})
}
}

/// AccountEntryExtView is a borrowing equivalent of [`AccountEntryExt`], usable in
/// const contexts and convertible to the owned type via [`From`]/[`Into`].
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[allow(clippy::large_enum_variant)]
pub enum AccountEntryExtView<'a> {
V0,
V1(AccountEntryExtensionV1View<'a>),
}

#[cfg(feature = "alloc")]
impl From<&AccountEntryExtView<'_>> for AccountEntryExt {
#[must_use]
fn from(v: &AccountEntryExtView<'_>) -> Self {
#[allow(clippy::match_same_arms)]
match v {
AccountEntryExtView::V0 => Self::V0,
AccountEntryExtView::V1(value) => Self::V1(value.into()),
}
}
}

#[cfg(feature = "alloc")]
impl From<AccountEntryExtView<'_>> for AccountEntryExt {
#[must_use]
fn from(v: AccountEntryExtView<'_>) -> Self {
Self::from(&v)
}
}

impl AccountEntryExtView<'_> {
#[must_use]
pub const fn discriminant(&self) -> i32 {
#[allow(clippy::match_same_arms)]
match self {
Self::V0 => 0,
Self::V1(_) => 1,
}
}
}

impl WriteXdr for AccountEntryExtView<'_> {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.discriminant().write_xdr(w)?;
#[allow(clippy::match_same_arms)]
match self {
Self::V0 => ().write_xdr(w)?,
Self::V1(v) => v.write_xdr(w)?,
};
Ok(())
})
}
}
38 changes: 38 additions & 0 deletions src/generated/account_entry_extension_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,41 @@ impl WriteXdr for AccountEntryExtensionV1 {
})
}
}

/// AccountEntryExtensionV1View is a borrowing equivalent of [`AccountEntryExtensionV1`], usable in
/// const contexts and convertible to the owned type via [`From`]/[`Into`].
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct AccountEntryExtensionV1View<'a> {
pub liabilities: Liabilities,
pub ext: AccountEntryExtensionV1ExtView<'a>,
}

#[cfg(feature = "alloc")]
impl From<&AccountEntryExtensionV1View<'_>> for AccountEntryExtensionV1 {
#[must_use]
fn from(v: &AccountEntryExtensionV1View<'_>) -> Self {
Self {
liabilities: v.liabilities.clone(),
ext: (&v.ext).into(),
}
}
}

#[cfg(feature = "alloc")]
impl From<AccountEntryExtensionV1View<'_>> for AccountEntryExtensionV1 {
#[must_use]
fn from(v: AccountEntryExtensionV1View<'_>) -> Self {
Self::from(&v)
}
}

impl WriteXdr for AccountEntryExtensionV1View<'_> {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.liabilities.write_xdr(w)?;
self.ext.write_xdr(w)?;
Ok(())
})
}
}
55 changes: 55 additions & 0 deletions src/generated/account_entry_extension_v1_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,58 @@ impl WriteXdr for AccountEntryExtensionV1Ext {
})
}
}

/// AccountEntryExtensionV1ExtView is a borrowing equivalent of [`AccountEntryExtensionV1Ext`], usable in
/// const contexts and convertible to the owned type via [`From`]/[`Into`].
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[allow(clippy::large_enum_variant)]
pub enum AccountEntryExtensionV1ExtView<'a> {
V0,
V2(AccountEntryExtensionV2View<'a>),
}

#[cfg(feature = "alloc")]
impl From<&AccountEntryExtensionV1ExtView<'_>> for AccountEntryExtensionV1Ext {
#[must_use]
fn from(v: &AccountEntryExtensionV1ExtView<'_>) -> Self {
#[allow(clippy::match_same_arms)]
match v {
AccountEntryExtensionV1ExtView::V0 => Self::V0,
AccountEntryExtensionV1ExtView::V2(value) => Self::V2(value.into()),
}
}
}

#[cfg(feature = "alloc")]
impl From<AccountEntryExtensionV1ExtView<'_>> for AccountEntryExtensionV1Ext {
#[must_use]
fn from(v: AccountEntryExtensionV1ExtView<'_>) -> Self {
Self::from(&v)
}
}

impl AccountEntryExtensionV1ExtView<'_> {
#[must_use]
pub const fn discriminant(&self) -> i32 {
#[allow(clippy::match_same_arms)]
match self {
Self::V0 => 0,
Self::V2(_) => 2,
}
}
}

impl WriteXdr for AccountEntryExtensionV1ExtView<'_> {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.discriminant().write_xdr(w)?;
#[allow(clippy::match_same_arms)]
match self {
Self::V0 => ().write_xdr(w)?,
Self::V2(v) => v.write_xdr(w)?,
};
Ok(())
})
}
}
44 changes: 44 additions & 0 deletions src/generated/account_entry_extension_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,47 @@ impl WriteXdr for AccountEntryExtensionV2 {
})
}
}

/// AccountEntryExtensionV2View is a borrowing equivalent of [`AccountEntryExtensionV2`], usable in
/// const contexts and convertible to the owned type via [`From`]/[`Into`].
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct AccountEntryExtensionV2View<'a> {
pub num_sponsored: u32,
pub num_sponsoring: u32,
pub signer_sponsoring_i_ds: VecMView<'a, SponsorshipDescriptor, 20>,
pub ext: AccountEntryExtensionV2Ext,
}

#[cfg(feature = "alloc")]
impl From<&AccountEntryExtensionV2View<'_>> for AccountEntryExtensionV2 {
#[must_use]
fn from(v: &AccountEntryExtensionV2View<'_>) -> Self {
Self {
num_sponsored: v.num_sponsored,
num_sponsoring: v.num_sponsoring,
signer_sponsoring_i_ds: v.signer_sponsoring_i_ds.to_vecm(),
ext: v.ext.clone(),
}
}
}

#[cfg(feature = "alloc")]
impl From<AccountEntryExtensionV2View<'_>> for AccountEntryExtensionV2 {
#[must_use]
fn from(v: AccountEntryExtensionV2View<'_>) -> Self {
Self::from(&v)
}
}

impl WriteXdr for AccountEntryExtensionV2View<'_> {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.num_sponsored.write_xdr(w)?;
self.num_sponsoring.write_xdr(w)?;
self.signer_sponsoring_i_ds.write_xdr(w)?;
self.ext.write_xdr(w)?;
Ok(())
})
}
}
41 changes: 41 additions & 0 deletions src/generated/auth_cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,44 @@ impl WriteXdr for AuthCert {
})
}
}

/// AuthCertView is a borrowing equivalent of [`AuthCert`], usable in
/// const contexts and convertible to the owned type via [`From`]/[`Into`].
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct AuthCertView<'a> {
pub pubkey: Curve25519Public,
pub expiration: u64,
pub sig: SignatureView<'a>,
}

#[cfg(feature = "alloc")]
impl From<&AuthCertView<'_>> for AuthCert {
#[must_use]
fn from(v: &AuthCertView<'_>) -> Self {
Self {
pubkey: v.pubkey.clone(),
expiration: v.expiration,
sig: (&v.sig).into(),
}
}
}

#[cfg(feature = "alloc")]
impl From<AuthCertView<'_>> for AuthCert {
#[must_use]
fn from(v: AuthCertView<'_>) -> Self {
Self::from(&v)
}
}

impl WriteXdr for AuthCertView<'_> {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.pubkey.write_xdr(w)?;
self.expiration.write_xdr(w)?;
self.sig.write_xdr(w)?;
Ok(())
})
}
}
51 changes: 51 additions & 0 deletions src/generated/authenticated_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,54 @@ impl WriteXdr for AuthenticatedMessage {
})
}
}

/// AuthenticatedMessageView is a borrowing equivalent of [`AuthenticatedMessage`], usable in
/// const contexts and convertible to the owned type via [`From`]/[`Into`].
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[allow(clippy::large_enum_variant)]
pub enum AuthenticatedMessageView<'a> {
V0(AuthenticatedMessageV0View<'a>),
}

#[cfg(feature = "alloc")]
impl From<&AuthenticatedMessageView<'_>> for AuthenticatedMessage {
#[must_use]
fn from(v: &AuthenticatedMessageView<'_>) -> Self {
#[allow(clippy::match_same_arms)]
match v {
AuthenticatedMessageView::V0(value) => Self::V0(value.into()),
}
}
}

#[cfg(feature = "alloc")]
impl From<AuthenticatedMessageView<'_>> for AuthenticatedMessage {
#[must_use]
fn from(v: AuthenticatedMessageView<'_>) -> Self {
Self::from(&v)
}
}

impl AuthenticatedMessageView<'_> {
#[must_use]
pub const fn discriminant(&self) -> u32 {
#[allow(clippy::match_same_arms)]
match self {
Self::V0(_) => 0,
}
}
}

impl WriteXdr for AuthenticatedMessageView<'_> {
#[cfg(feature = "std")]
fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
w.with_limited_depth(|w| {
self.discriminant().write_xdr(w)?;
#[allow(clippy::match_same_arms)]
match self {
Self::V0(v) => v.write_xdr(w)?,
};
Ok(())
})
}
}
Loading
Loading