Skip to content

Commit 3238fd6

Browse files
committed
Update README with a bit more info on how Rusty things are mapped
Fixes #160
1 parent 6423e7a commit 3238fd6

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,39 @@ The auto-generated code contains copies of the Rust documentation, which can als
77
[docs.rs/lightning](https://docs.rs/lightning). High-level documentation of the API can be found at
88
[lightningdevkit.org](https://lightningdevkit.org).
99

10+
API Mappings
11+
============
12+
13+
As the bindings are auto-generated, they often read fairly verbose with lots of additional type
14+
information compared to what might be expected with a native interface. A brief understanding of
15+
some Rust nomenclature will help read bindings:
16+
17+
## `Result`
18+
19+
Rust APIs make heavy use of the `Result` enum. They can either be in an `Ok` state, with an
20+
optional value or an `Err` state, with an optional error value. These often appear as
21+
`Result_OKValueTypeErrValueTypeZ` in bindings. Subclasses are build for the `Ok` and `Err` states,
22+
with the appropriate values available in the subclasses which all instances will be of.
23+
24+
## `Option`
25+
26+
Similar to `Result`, Rust APIs make heavy use of the `Option` enum. Like `Result`, they may contain
27+
a value in the `Some` state, but may contain no value in the `None` state. They are mapped
28+
similarly to `Result`s, usually as `Option_SomeValueTypeZ`.
29+
30+
## Tuples
31+
32+
Rust APIs occasionally use tuples, which are simply mapped as a tuple type like
33+
`TwoTuple_FirstValueTypeSecondValueTypeZ`. Individual elements can be fetched or set with `get_a()`,
34+
`get_b()`, `set_a(..)`, etc.
35+
36+
## Tuple Types
37+
38+
Rust APIs occasionally build structs which are simply a named tuple type. These appear in rust as,
39+
eg, `struct PrintableString(String)`, and in the bindings as simply the class name (eg
40+
`class PrintableString`). The value(s) in the tuple can be fetched or set with `get_a()`,
41+
`get_b()`, `set_a(..)`, etc.
42+
1043
Building
1144
========
1245

@@ -42,8 +75,8 @@ the browser you will need to provide your own bridge from `SocketDescriptor` to
4275

4376
# C#
4477

45-
The C# bindings are functionally complete, but should be considered alpha quality. They are brand
46-
new and likely contain bugs or memory leaks.
78+
The C# bindings are functionally complete, but should be considered beta quality. As they are
79+
relatively new, unexpected issues remain possible, and bug reports are welcome.
4780

4881
## General
4982

0 commit comments

Comments
 (0)