]> git.bitcoin.ninja Git - rust-lightning/commit
[bindings] Convert manual `_read` implementations to return Results
authorMatt Corallo <git@bluematt.me>
Wed, 30 Dec 2020 22:30:59 +0000 (17:30 -0500)
committerMatt Corallo <git@bluematt.me>
Fri, 15 Jan 2021 00:49:14 +0000 (19:49 -0500)
commitb4e0907c6e22264b398582e5b918644cbc1377ac
treed31ffeea1ef2b83b3099eee4272c5c06aa4eab05
parenta54b230e846b563acdb949eef2e6bbf9937b1831
[bindings] Convert manual `_read` implementations to return Results

Previously, manual `*_read` implementations were only defined for
types with inner fields, which were set to NULL to indicate read
errors. This prevents exposing `*_read` for several other types,
including tuples (which are needed for `ChannelManager`/
`ChannelMonitors`) and enums (which includes `Event`s, though users
likely never need to call that directly). Further, this means we
don't expose the actual error enum (which is likely no big deal,
but is still nice).

Here, we instead create the `Result<Object, DecodeError>` type and
then pass it through the normal type conversion functions, giving
us access to any types which we can convert normally.
c-bindings-gen/src/main.rs