Skip to content

Commit 1b618d4

Browse files
committed
f readme - update for new reference flag
1 parent f1d8845 commit 1b618d4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lightning-c-bindings/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ type getting an `LDK` prefix to their native Rust type names.
1919
Structs are mapped into a simple wrapper containing a pointer to the native Rust-Lightning object
2020
and a flag to indicate whether the object is owned or only a reference. Such mappings usually
2121
generate a `X_free` function which must be called to release the allocated resources. Note that
22-
calling `X_free` will do nothing if the underlying pointer is NULL or if the reference flag is set.
22+
calling `X_free` will do nothing if the underlying pointer is NULL or if the `is_owned` flag is not
23+
set.
2324

2425
You MUST NOT create such wrapper structs manually, relying instead on constructors which have been
2526
mapped from equivalent Rust constructors.
2627

27-
Note that, thanks to the is-reference flag and the pointer being NULLable, such structs effectively
28+
Note that, thanks to the is-owned flag and the pointer being NULLable, such structs effectively
2829
represent `RustType`, `&RustType`, and `Option<RustType>`. Check the corresponding Rust
2930
documentation for the function or struct you are using to ensure you use the correct call semantics.
3031
The passed struct must match the call semantics or an assertion failure or NULL pointer dereference
@@ -35,7 +36,7 @@ For example, this is the mapping of ChannelManager.
3536
typedef struct MUST_USE_STRUCT LDKChannelManager {
3637
/** ... */
3738
LDKnativeChannelManager *inner;
38-
bool _underlying_ref;
39+
bool is_owned;
3940
} LDKChannelManager;
4041
```
4142

@@ -141,10 +142,10 @@ as their first argument. Free-standing functions are mapped simply as `function_
141142
relevant mapped type arguments.
142143

143144
Functions which return `&OpaqueRustType` and which return `OpaqueRustType` are both mapped to a
144-
function returning an owned wrapper struct. The `_underlying_ref` flag (see above) will be set to
145-
indicate that the pointed-to Rust object is owned or only a reference. Thus, when implementing a
146-
function which Rust will call or calling a Rust function, you should check the Rust documentation
147-
for the function to determine whether an owned or referenced object is expected or returned.
145+
function returning an owned wrapper struct. The `is_owned` flag (see above) will be set to indicate
146+
that the pointed-to Rust object is owned or only a reference. Thus, when implementing a function
147+
which Rust will call or calling a Rust function, you should check the Rust documentation for the
148+
function to determine whether an owned or referenced object is expected or returned.
148149

149150
Similarly, when a function takes an `Option<RustType>` as a parameter or a return value, the C type
150151
is the same as if it took only `RustType`, with the `inner` field set to NULL to indicate None. For

0 commit comments

Comments
 (0)