Skip to content

Commit 6e2fc2a

Browse files
committed
Migrate simple flat enums to UniFFI proc-macro export
Migrate `WordCount`, `PaymentDirection`, `PaymentStatus`, and `AsyncPaymentsRole` from UDL enum definitions to proc-macro `#[derive(uniffi::Enum)]` on their Rust source types, replacing the UDL definitions with `typedef enum` references. Generated with the help of AI (Claude Code). Co-Authored-By: HAL 9000
1 parent 3fb2bef commit 6e2fc2a

4 files changed

Lines changed: 8 additions & 20 deletions

File tree

bindings/ldk_node.udl

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ enum EntropyError {
7171
"InvalidSeedFile",
7272
};
7373

74-
enum WordCount {
75-
"Words12",
76-
"Words15",
77-
"Words18",
78-
"Words21",
79-
"Words24",
80-
};
74+
typedef enum WordCount;
8175

8276
[Remote]
8377
enum LogLevel {
@@ -448,16 +442,9 @@ interface UnifiedPaymentResult {
448442
Bolt12(PaymentId payment_id);
449443
};
450444

451-
enum PaymentDirection {
452-
"Inbound",
453-
"Outbound",
454-
};
445+
typedef enum PaymentDirection;
455446

456-
enum PaymentStatus {
457-
"Pending",
458-
"Succeeded",
459-
"Failed",
460-
};
447+
typedef enum PaymentStatus;
461448

462449
dictionary LSPFeeLimits {
463450
u64? max_total_opening_fee_msat;
@@ -744,10 +731,7 @@ enum Currency {
744731
"Signet",
745732
};
746733

747-
enum AsyncPaymentsRole {
748-
"Client",
749-
"Server",
750-
};
734+
typedef enum AsyncPaymentsRole;
751735

752736
dictionary RouteHintHop {
753737
PublicKey src_node_id;

src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ impl From<MaxDustHTLCExposure> for LdkMaxDustHTLCExposure {
595595
}
596596

597597
#[derive(Debug, Clone, Copy)]
598+
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
598599
/// The role of the node in an asynchronous payments context.
599600
///
600601
/// See <https://github.com/lightning/bolts/pull/1149> for more information about the async payments protocol.

src/entropy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub fn generate_entropy_mnemonic(word_count: Option<WordCount>) -> Mnemonic {
125125

126126
/// Supported BIP39 mnemonic word counts for entropy generation.
127127
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
128+
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
128129
pub enum WordCount {
129130
/// 12-word mnemonic (128-bit entropy)
130131
Words12,

src/payment/store.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ impl StorableObject for PaymentDetails {
317317

318318
/// Represents the direction of a payment.
319319
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
320+
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
320321
pub enum PaymentDirection {
321322
/// The payment is inbound.
322323
Inbound,
@@ -331,6 +332,7 @@ impl_writeable_tlv_based_enum!(PaymentDirection,
331332

332333
/// Represents the current status of a payment.
333334
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
335+
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
334336
pub enum PaymentStatus {
335337
/// The payment is still pending.
336338
Pending,

0 commit comments

Comments
 (0)