+/// Result of successfully [sending an onion message].
+///
+/// [sending an onion message]: OnionMessenger::send_onion_message
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum SendSuccess {
+ /// The message was buffered and will be sent once it is processed by
+ /// [`OnionMessageHandler::next_onion_message_for_peer`].
+ Buffered,
+ /// The message was buffered and will be sent once the node is connected as a peer and it is
+ /// processed by [`OnionMessageHandler::next_onion_message_for_peer`].
+ BufferedAwaitingConnection(
+ crate::c_types::PublicKey),
+}
+use lightning::onion_message::messenger::SendSuccess as SendSuccessImport;
+pub(crate) type nativeSendSuccess = SendSuccessImport;
+
+impl SendSuccess {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeSendSuccess {
+ match self {
+ SendSuccess::Buffered => nativeSendSuccess::Buffered,
+ SendSuccess::BufferedAwaitingConnection (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ nativeSendSuccess::BufferedAwaitingConnection (
+ a_nonref.into_rust(),
+ )
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeSendSuccess {
+ match self {
+ SendSuccess::Buffered => nativeSendSuccess::Buffered,
+ SendSuccess::BufferedAwaitingConnection (mut a, ) => {
+ nativeSendSuccess::BufferedAwaitingConnection (
+ a.into_rust(),
+ )
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &SendSuccessImport) -> Self {
+ let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSendSuccess) };
+ match native {
+ nativeSendSuccess::Buffered => SendSuccess::Buffered,
+ nativeSendSuccess::BufferedAwaitingConnection (ref a, ) => {
+ let mut a_nonref = Clone::clone(a);
+ SendSuccess::BufferedAwaitingConnection (
+ crate::c_types::PublicKey::from_rust(&a_nonref),
+ )
+ },
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeSendSuccess) -> Self {
+ match native {
+ nativeSendSuccess::Buffered => SendSuccess::Buffered,
+ nativeSendSuccess::BufferedAwaitingConnection (mut a, ) => {
+ SendSuccess::BufferedAwaitingConnection (
+ crate::c_types::PublicKey::from_rust(&a),
+ )
+ },
+ }
+ }
+}
+/// Frees any resources used by the SendSuccess
+#[no_mangle]
+pub extern "C" fn SendSuccess_free(this_ptr: SendSuccess) { }
+/// Creates a copy of the SendSuccess
+#[no_mangle]
+pub extern "C" fn SendSuccess_clone(orig: &SendSuccess) -> SendSuccess {
+ orig.clone()
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn SendSuccess_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SendSuccess)).clone() })) as *mut c_void
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn SendSuccess_free_void(this_ptr: *mut c_void) {
+ let _ = unsafe { Box::from_raw(this_ptr as *mut SendSuccess) };
+}
+#[no_mangle]
+/// Utility method to constructs a new Buffered-variant SendSuccess
+pub extern "C" fn SendSuccess_buffered() -> SendSuccess {
+ SendSuccess::Buffered}
+#[no_mangle]
+/// Utility method to constructs a new BufferedAwaitingConnection-variant SendSuccess
+pub extern "C" fn SendSuccess_buffered_awaiting_connection(a: crate::c_types::PublicKey) -> SendSuccess {
+ SendSuccess::BufferedAwaitingConnection(a, )
+}
+/// Get a string which allows debug introspection of a SendSuccess object
+pub extern "C" fn SendSuccess_debug_str_void(o: *const c_void) -> Str {
+ alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::messenger::SendSuccess }).into()}
+/// Checks if two SendSuccesss contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn SendSuccess_eq(a: &SendSuccess, b: &SendSuccess) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}