From 4eaa0bf8e5019dd60cd99f3ba9391cdc11dc22c2 Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Fri, 1 Nov 2024 18:06:12 +0100 Subject: [PATCH] [#498] Adjust C API --- iceoryx2-ffi/ffi/src/api/subscriber.rs | 28 ++++++++++++++------------ iceoryx2/src/port/publisher.rs | 5 +---- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/iceoryx2-ffi/ffi/src/api/subscriber.rs b/iceoryx2-ffi/ffi/src/api/subscriber.rs index af0ab03e0..e041c6ad1 100644 --- a/iceoryx2-ffi/ffi/src/api/subscriber.rs +++ b/iceoryx2-ffi/ffi/src/api/subscriber.rs @@ -273,7 +273,7 @@ pub unsafe extern "C" fn iox2_subscriber_receive( let subscriber = &mut *subscriber_handle.as_type(); match subscriber.service_type { - iox2_service_type_e::IPC => match subscriber.value.as_ref().ipc.receive() { + iox2_service_type_e::IPC => match subscriber.value.as_ref().ipc.receive_custom_payload() { Ok(Some(sample)) => { let (sample_struct_ptr, deleter) = init_sample_struct_ptr(sample_struct_ptr); (*sample_struct_ptr).init( @@ -286,19 +286,21 @@ pub unsafe extern "C" fn iox2_subscriber_receive( Ok(None) => (), Err(error) => return error.into_c_int(), }, - iox2_service_type_e::LOCAL => match subscriber.value.as_ref().local.receive() { - Ok(Some(sample)) => { - let (sample_struct_ptr, deleter) = init_sample_struct_ptr(sample_struct_ptr); - (*sample_struct_ptr).init( - subscriber.service_type, - SampleUnion::new_local(sample), - deleter, - ); - *sample_handle_ptr = (*sample_struct_ptr).as_handle(); + iox2_service_type_e::LOCAL => { + match subscriber.value.as_ref().local.receive_custom_payload() { + Ok(Some(sample)) => { + let (sample_struct_ptr, deleter) = init_sample_struct_ptr(sample_struct_ptr); + (*sample_struct_ptr).init( + subscriber.service_type, + SampleUnion::new_local(sample), + deleter, + ); + *sample_handle_ptr = (*sample_struct_ptr).as_handle(); + } + Ok(None) => (), + Err(error) => return error.into_c_int(), } - Ok(None) => (), - Err(error) => return error.into_c_int(), - }, + } } IOX2_OK diff --git a/iceoryx2/src/port/publisher.rs b/iceoryx2/src/port/publisher.rs index d580d0443..ce4b9fb37 100644 --- a/iceoryx2/src/port/publisher.rs +++ b/iceoryx2/src/port/publisher.rs @@ -1042,10 +1042,7 @@ impl PublisherLoanError, > { // TypeVariant::Dynamic == slice and only here it makes sense to loan more than one element - debug_assert!( - slice_len == 1 - || (slice_len != 1 && self.payload_type_variant() == TypeVariant::Dynamic) - ); + debug_assert!(slice_len == 1 || self.payload_type_variant() == TypeVariant::Dynamic); self.loan_slice_uninit_impl(slice_len, self.payload_size * slice_len) }