Skip to content

Commit 8cb2bd3

Browse files
committed
Migrate EntropyError and BuildError to UniFFI proc-macro export
Add `#[derive(uniffi::Error)]` to `EntropyError` and `BuildError`, replacing their UDL definitions with `typedef enum` references. Generated with the help of AI (Claude Code). Co-Authored-By: HAL 9000
1 parent 6e2fc2a commit 8cb2bd3

3 files changed

Lines changed: 4 additions & 21 deletions

File tree

bindings/ldk_node.udl

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ interface NodeEntropy {
6666
constructor(string seed_path);
6767
};
6868

69-
enum EntropyError {
70-
"InvalidSeedBytes",
71-
"InvalidSeedFile",
72-
};
69+
typedef enum EntropyError;
7370

7471
typedef enum WordCount;
7572

@@ -379,23 +376,7 @@ dictionary BestBlock {
379376
u32 height;
380377
};
381378

382-
[Error]
383-
enum BuildError {
384-
"InvalidSystemTime",
385-
"InvalidChannelMonitor",
386-
"InvalidListeningAddresses",
387-
"InvalidAnnouncementAddresses",
388-
"InvalidNodeAlias",
389-
"RuntimeSetupFailed",
390-
"ReadFailed",
391-
"WriteFailed",
392-
"StoragePathAccessFailed",
393-
"KVStoreSetupFailed",
394-
"WalletSetupFailed",
395-
"LoggerSetupFailed",
396-
"NetworkMismatch",
397-
"AsyncPaymentsConfigMismatch",
398-
};
379+
typedef enum BuildError;
399380

400381
[Trait, WithForeign]
401382
interface VssHeaderProvider {

src/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ impl std::fmt::Debug for LogWriterConfig {
154154
///
155155
/// [`Node`]: crate::Node
156156
#[derive(Debug, Clone, PartialEq)]
157+
#[cfg_attr(feature = "uniffi", derive(uniffi::Error))]
157158
pub enum BuildError {
158159
/// The current system time is invalid, clocks might have gone backwards.
159160
InvalidSystemTime,

src/entropy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::io;
1616

1717
/// An error that could arise during [`NodeEntropy`] construction.
1818
#[derive(Debug, Clone, PartialEq)]
19+
#[cfg_attr(feature = "uniffi", derive(uniffi::Error))]
1920
pub enum EntropyError {
2021
/// The given seed bytes are invalid, e.g., have invalid length.
2122
InvalidSeedBytes,

0 commit comments

Comments
 (0)