Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
78e1d71
add borrowed Ref variants of generated types
leighmcculloch Jul 27, 2026
3c2c077
fix VecMRef Copy bound and cfg-branch Ref lifetime
leighmcculloch Jul 27, 2026
1fd5d24
impl WriteXdr for Ref types
leighmcculloch Jul 28, 2026
552d5d0
format ref_types test with rustfmt
leighmcculloch Jul 28, 2026
d6774bc
regenerate Ref types without ungated CAP cfgs
leighmcculloch Aug 5, 2026
b6bf245
alias Ref types that do not borrow
leighmcculloch Aug 5, 2026
61db46c
rename borrowing Ref types to View
leighmcculloch Aug 6, 2026
6580c72
emit View only for unconditional borrowers
leighmcculloch Aug 6, 2026
69ec52c
give View const try_from_slice/try_from_str
leighmcculloch Aug 25, 2026
19442e2
rename View panic ctors to try_from_*_or_panic
leighmcculloch Sep 2, 2026
bc91d27
use xdr size consts in View types
leighmcculloch Sep 5, 2026
d4f6049
rewrite View tests around mirror invariants
leighmcculloch Sep 7, 2026
7da9d61
convert Views to owned through an IntoOwned trait
leighmcculloch Sep 7, 2026
1fb121d
make IntoOwned crate-private
leighmcculloch Sep 7, 2026
152bc05
convert Views to owned from a reference
leighmcculloch Sep 7, 2026
b95b6b4
box cyclic View fields at the call site
leighmcculloch Sep 7, 2026
9c3fd4c
convert Views to owned by value
leighmcculloch Sep 7, 2026
e4090fc
spell out the identity IntoOwned impls
leighmcculloch Sep 7, 2026
75ffca2
trim redundancy from the View tests
leighmcculloch Sep 7, 2026
01a42aa
remove doc
leighmcculloch Sep 7, 2026
dd3daa9
rewrite View tests around owned mirrors
leighmcculloch Sep 7, 2026
d1722e1
gate the View tests by feature
leighmcculloch Sep 7, 2026
71095d8
rename the View suffix to Ref
leighmcculloch Sep 7, 2026
35fc497
share the envelope fixture between tests
leighmcculloch Sep 7, 2026
629d891
rename ref and owned fixture helpers
leighmcculloch Sep 8, 2026
e3144c7
format transactionenvelope in doc comment
leighmcculloch Sep 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
695 changes: 694 additions & 1 deletion src/generated.rs

Large diffs are not rendered by default.

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

/// AccountEntryRef 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 AccountEntryRef<'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: String32Ref<'a>,
pub thresholds: Thresholds,
pub signers: VecMRef<'a, SignerRef<'a>, MAX_SIGNERS>,
pub ext: AccountEntryExtRef<'a>,
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountEntryRef<'_> {
type Owned = AccountEntry;
fn into_owned(self) -> AccountEntry {
AccountEntry {
account_id: self.account_id.into_owned(),
balance: self.balance.into_owned(),
seq_num: self.seq_num.into_owned(),
num_sub_entries: self.num_sub_entries.into_owned(),
inflation_dest: self.inflation_dest.into_owned(),
flags: self.flags.into_owned(),
home_domain: self.home_domain.into_owned(),
thresholds: self.thresholds.into_owned(),
signers: self.signers.into_owned(),
ext: self.ext.into_owned(),
}
}
}

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

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

impl WriteXdr for AccountEntryRef<'_> {
#[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(())
})
}
}
63 changes: 63 additions & 0 deletions src/generated/account_entry_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,66 @@ impl WriteXdr for AccountEntryExt {
})
}
}

/// AccountEntryExtRef 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 AccountEntryExtRef<'a> {
V0,
V1(AccountEntryExtensionV1Ref<'a>),
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountEntryExtRef<'_> {
type Owned = AccountEntryExt;
fn into_owned(self) -> AccountEntryExt {
#[allow(clippy::match_same_arms)]
match self {
AccountEntryExtRef::V0 => AccountEntryExt::V0,
AccountEntryExtRef::V1(value) => AccountEntryExt::V1(value.into_owned()),
}
}
}

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

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

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

impl WriteXdr for AccountEntryExtRef<'_> {
#[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(())
})
}
}
46 changes: 46 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,49 @@ impl WriteXdr for AccountEntryExtensionV1 {
})
}
}

/// AccountEntryExtensionV1Ref 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 AccountEntryExtensionV1Ref<'a> {
pub liabilities: Liabilities,
pub ext: AccountEntryExtensionV1ExtRef<'a>,
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountEntryExtensionV1Ref<'_> {
type Owned = AccountEntryExtensionV1;
fn into_owned(self) -> AccountEntryExtensionV1 {
AccountEntryExtensionV1 {
liabilities: self.liabilities.into_owned(),
ext: self.ext.into_owned(),
}
}
}

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

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

impl WriteXdr for AccountEntryExtensionV1Ref<'_> {
#[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(())
})
}
}
65 changes: 65 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,68 @@ impl WriteXdr for AccountEntryExtensionV1Ext {
})
}
}

/// AccountEntryExtensionV1ExtRef 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 AccountEntryExtensionV1ExtRef<'a> {
V0,
V2(AccountEntryExtensionV2Ref<'a>),
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountEntryExtensionV1ExtRef<'_> {
type Owned = AccountEntryExtensionV1Ext;
fn into_owned(self) -> AccountEntryExtensionV1Ext {
#[allow(clippy::match_same_arms)]
match self {
AccountEntryExtensionV1ExtRef::V0 => AccountEntryExtensionV1Ext::V0,
AccountEntryExtensionV1ExtRef::V2(value) => {
AccountEntryExtensionV1Ext::V2(value.into_owned())
}
}
}
}

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

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

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

impl WriteXdr for AccountEntryExtensionV1ExtRef<'_> {
#[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(())
})
}
}
52 changes: 52 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,55 @@ impl WriteXdr for AccountEntryExtensionV2 {
})
}
}

/// AccountEntryExtensionV2Ref 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 AccountEntryExtensionV2Ref<'a> {
pub num_sponsored: u32,
pub num_sponsoring: u32,
pub signer_sponsoring_i_ds: VecMRef<'a, SponsorshipDescriptor, MAX_SIGNERS>,
pub ext: AccountEntryExtensionV2Ext,
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountEntryExtensionV2Ref<'_> {
type Owned = AccountEntryExtensionV2;
fn into_owned(self) -> AccountEntryExtensionV2 {
AccountEntryExtensionV2 {
num_sponsored: self.num_sponsored.into_owned(),
num_sponsoring: self.num_sponsoring.into_owned(),
signer_sponsoring_i_ds: self.signer_sponsoring_i_ds.into_owned(),
ext: self.ext.into_owned(),
}
}
}

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

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

impl WriteXdr for AccountEntryExtensionV2Ref<'_> {
#[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(())
})
}
}
8 changes: 8 additions & 0 deletions src/generated/account_entry_extension_v2_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,11 @@ impl WriteXdr for AccountEntryExtensionV2Ext {
})
}
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountEntryExtensionV2Ext {
type Owned = AccountEntryExtensionV2Ext;
fn into_owned(self) -> AccountEntryExtensionV2Ext {
self
}
}
8 changes: 8 additions & 0 deletions src/generated/account_entry_extension_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ impl WriteXdr for AccountEntryExtensionV3 {
})
}
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountEntryExtensionV3 {
type Owned = AccountEntryExtensionV3;
fn into_owned(self) -> AccountEntryExtensionV3 {
self
}
}
8 changes: 8 additions & 0 deletions src/generated/account_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,11 @@ impl WriteXdr for AccountFlags {
})
}
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountFlags {
type Owned = AccountFlags;
fn into_owned(self) -> AccountFlags {
self
}
}
8 changes: 8 additions & 0 deletions src/generated/account_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@ impl WriteXdr for AccountId {
w.with_limited_depth(|w| self.0.write_xdr(w))
}
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountId {
type Owned = AccountId;
fn into_owned(self) -> AccountId {
self
}
}
8 changes: 8 additions & 0 deletions src/generated/account_merge_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,11 @@ impl WriteXdr for AccountMergeResult {
})
}
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountMergeResult {
type Owned = AccountMergeResult;
fn into_owned(self) -> AccountMergeResult {
self
}
}
8 changes: 8 additions & 0 deletions src/generated/account_merge_result_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,11 @@ impl WriteXdr for AccountMergeResultCode {
})
}
}

#[cfg(feature = "alloc")]
impl IntoOwned for AccountMergeResultCode {
type Owned = AccountMergeResultCode;
fn into_owned(self) -> AccountMergeResultCode {
self
}
}
8 changes: 8 additions & 0 deletions src/generated/allow_trust_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,11 @@ impl WriteXdr for AllowTrustOp {
})
}
}

#[cfg(feature = "alloc")]
impl IntoOwned for AllowTrustOp {
type Owned = AllowTrustOp;
fn into_owned(self) -> AllowTrustOp {
self
}
}
Loading
Loading