+/// Waits until this [`Future`] completes or the given amount of time has elapsed.
+///
+/// Returns true if the [`Future`] completed, false if the time elapsed.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Future_wait_timeout(mut this_arg: crate::lightning::util::wakers::Future, mut max_wait: u64) -> bool {
+ let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).wait_timeout(core::time::Duration::from_secs(max_wait));
+ ret
+}
+
+
+use lightning::util::wakers::Sleeper as nativeSleeperImport;
+pub(crate) type nativeSleeper = nativeSleeperImport;
+
+/// A struct which can be used to select across many [`Future`]s at once without relying on a full
+/// async context.
+#[must_use]
+#[repr(C)]
+pub struct Sleeper {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeSleeper,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for Sleeper {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeSleeper>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the Sleeper, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn Sleeper_free(this_obj: Sleeper) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn Sleeper_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSleeper) };
+}
+#[allow(unused)]
+impl Sleeper {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeSleeper {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSleeper {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeSleeper {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// Constructs a new sleeper from one future, allowing blocking on it.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Sleeper_from_single_future(mut future: crate::lightning::util::wakers::Future) -> crate::lightning::util::wakers::Sleeper {
+ let mut ret = lightning::util::wakers::Sleeper::from_single_future(*unsafe { Box::from_raw(future.take_inner()) });
+ crate::lightning::util::wakers::Sleeper { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+/// Constructs a new sleeper from two futures, allowing blocking on both at once.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Sleeper_from_two_futures(mut fut_a: crate::lightning::util::wakers::Future, mut fut_b: crate::lightning::util::wakers::Future) -> crate::lightning::util::wakers::Sleeper {
+ let mut ret = lightning::util::wakers::Sleeper::from_two_futures(*unsafe { Box::from_raw(fut_a.take_inner()) }, *unsafe { Box::from_raw(fut_b.take_inner()) });
+ crate::lightning::util::wakers::Sleeper { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}