From 81c8df191bcdcccc1e2f1d2141331ea80c93cb5e Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 19 Nov 2021 20:11:56 +0000 Subject: [PATCH] Add helper method on results to return `result_ok` This fixes https://github.com/lightningdevkit/ldk-garbagecollected/issues/59 --- c-bindings-gen/src/blocks.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/c-bindings-gen/src/blocks.rs b/c-bindings-gen/src/blocks.rs index 5713578..6e6b897 100644 --- a/c-bindings-gen/src/blocks.rs +++ b/c-bindings-gen/src/blocks.rs @@ -124,6 +124,12 @@ pub fn write_result_block(w: &mut W, mangled_container: &str, writeln!(w, "\t}}").unwrap(); writeln!(w, "}}").unwrap(); + writeln!(w, "/// Checks if the given object is currently in the success state").unwrap(); + writeln!(w, "#[no_mangle]").unwrap(); + writeln!(w, "pub extern \"C\" fn {}_is_ok(o: &{}) -> bool {{", mangled_container, mangled_container).unwrap(); + writeln!(w, "\to.result_ok").unwrap(); + writeln!(w, "}}").unwrap(); + writeln!(w, "#[no_mangle]").unwrap(); writeln!(w, "/// Frees any resources used by the {}.", mangled_container).unwrap(); writeln!(w, "pub extern \"C\" fn {}_free(_res: {}) {{ }}", mangled_container, mangled_container).unwrap(); -- 2.30.2