X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Fln%2Ffeatures.rs;h=7bee3b0d7a0c5d1fe85607570479e0621eaefecd;hb=5271372bfe3ddc870c806f7b7ee13c4a7660e7e5;hp=ba3d77949de83d760591254ba84eb8853cf23cc0;hpb=ed6eb46f7b4e0d4c869ad08dffc600b4e93e2129;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/ln/features.rs b/lightning-c-bindings/src/lightning/ln/features.rs index ba3d779..7bee3b0 100644 --- a/lightning-c-bindings/src/lightning/ln/features.rs +++ b/lightning-c-bindings/src/lightning/ln/features.rs @@ -23,6 +23,7 @@ use std::str::FromStr; use std::ffi::c_void; +use core::convert::Infallible; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -30,6 +31,7 @@ mod sealed { use std::str::FromStr; use std::ffi::c_void; +use core::convert::Infallible; use bitcoin::hashes::Hash; use crate::c_types::*; @@ -148,7 +150,7 @@ pub extern "C" fn InvoiceFeatures_clone(orig: &InvoiceFeatures) -> InvoiceFeatur } use lightning::ln::features::InitFeatures as nativeInitFeaturesImport; -type nativeInitFeatures = nativeInitFeaturesImport; +pub(crate) type nativeInitFeatures = nativeInitFeaturesImport; /// Features used within an `init` message. #[must_use] @@ -178,7 +180,7 @@ impl Drop for InitFeatures { pub extern "C" fn InitFeatures_free(this_obj: InitFeatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInitFeatures); } } #[allow(unused)] @@ -199,7 +201,7 @@ impl InitFeatures { } use lightning::ln::features::NodeFeatures as nativeNodeFeaturesImport; -type nativeNodeFeatures = nativeNodeFeaturesImport; +pub(crate) type nativeNodeFeatures = nativeNodeFeaturesImport; /// Features used within a `node_announcement` message. #[must_use] @@ -229,7 +231,7 @@ impl Drop for NodeFeatures { pub extern "C" fn NodeFeatures_free(this_obj: NodeFeatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeNodeFeatures); } } #[allow(unused)] @@ -250,7 +252,7 @@ impl NodeFeatures { } use lightning::ln::features::ChannelFeatures as nativeChannelFeaturesImport; -type nativeChannelFeatures = nativeChannelFeaturesImport; +pub(crate) type nativeChannelFeatures = nativeChannelFeaturesImport; /// Features used within a `channel_announcement` message. #[must_use] @@ -280,7 +282,7 @@ impl Drop for ChannelFeatures { pub extern "C" fn ChannelFeatures_free(this_obj: ChannelFeatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelFeatures); } } #[allow(unused)] @@ -301,7 +303,7 @@ impl ChannelFeatures { } use lightning::ln::features::InvoiceFeatures as nativeInvoiceFeaturesImport; -type nativeInvoiceFeatures = nativeInvoiceFeaturesImport; +pub(crate) type nativeInvoiceFeatures = nativeInvoiceFeaturesImport; /// Features used within an invoice. #[must_use] @@ -331,7 +333,7 @@ impl Drop for InvoiceFeatures { pub extern "C" fn InvoiceFeatures_free(this_obj: InvoiceFeatures) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -extern "C" fn InvoiceFeatures_free_void(this_ptr: *mut c_void) { +pub(crate) extern "C" fn InvoiceFeatures_free_void(this_ptr: *mut c_void) { unsafe { let _ = Box::from_raw(this_ptr as *mut nativeInvoiceFeatures); } } #[allow(unused)] @@ -366,6 +368,15 @@ pub extern "C" fn InitFeatures_known() -> InitFeatures { InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_unknown_bits(this_arg: &InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -382,6 +393,15 @@ pub extern "C" fn NodeFeatures_known() -> NodeFeatures { NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_unknown_bits(this_arg: &NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -398,6 +418,15 @@ pub extern "C" fn ChannelFeatures_known() -> ChannelFeatures { ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_requires_unknown_bits(this_arg: &ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + /// Create a blank Features with no features set #[must_use] #[no_mangle] @@ -414,6 +443,15 @@ pub extern "C" fn InvoiceFeatures_known() -> InvoiceFeatures { InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceFeatures_requires_unknown_bits(this_arg: &InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + /// Returns whether the `payment_secret` feature is supported. #[must_use] #[no_mangle]