Skip to content

Conversation

@enigbe
Copy link
Owner

@enigbe enigbe commented Aug 5, 2025

What this PR does

In a bid to create a uniffi wrapper for PaymentPreimage as an
interface object, we also create bindings-specific variants for the
following types:

  • LightningBalance,
  • PaymentKind, and
  • Event,
    All of which have fields that hold object/interface instances -
    PaymentPreimage, ConfirmationStatus and ClosureReason.

This is not currently supported in uniffi 0.27.3

thread 'main' panicked at build.rs:10:59:
  called `Result::unwrap()` on an `Err` value: Objects cannot currently be used in enum variant data
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To workaround this limitation, we Arc these types and implement type conversion
for the new FFI types created.

Unfortunately this also does not build. Even though, according to the uniffi docs:

When you want to ... store object instances as fields in records,
the underlying Rust code will need to work with Arc directly,
to ensure that the code behaves in the way that UniFFI expects.

this Arc-ing the fields that hold PaymentPreimage, ConfirmationStatus,
& ClosureReason in the related enums is not sufficient to circumvent
the error associated with objects not being supported in enum variants.

Caused by:
  thread 'main' panicked at build.rs:10:59:
  called `Result::unwrap()` on an `Err` value: Objects cannot currently be used in enum variant data

Update

We discover that support for interface in enum variant fields have been added to uniffi 0.30.0
but this upgrade will bring in a significant amount of changes to the entire library, discounting
the boilerplate required to support exposing PaymentPreimage to FFI as an interface object.

Following conversations with maintainer, we agree to pause this feature work so that blocked
PRs can move forward. See some related conversation here.

enigbe added 2 commits July 30, 2025 20:53
In a bid to create a uniffi wrapper for PaymentPreimage,
we also create bindings-specific variants for the ffg types:
LightningBalance, PaymentKind, and Event, all of which have
fields that hold object/interface instances - PaymentPreimage,
ConfirmationStatus and ClosureReason.

We implement type conversion for the types created.

Unfortunately the build does not compile.
According to the uniffi docs:
"When you want to ... store object instances as fields in records,
 the underlying Rust code will need to work with Arc<T> directly,
 to ensure that the code behaves in the way that UniFFI expects."

Arc-ing the fields that hold PaymentPreimage, ConfirmationStatus,
& ClosureReason is not sufficient to circumvent the error
associated with objects not being supported in enum variants.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants