iceoryx2_ffi/api/
unique_subscriber_id.rs1#![allow(non_camel_case_types)]
14
15use iceoryx2::port::port_identifiers::UniqueSubscriberId;
16use iceoryx2_bb_elementary::static_assert::static_assert_ge;
17use iceoryx2_ffi_macros::iceoryx2_ffi;
18
19use crate::api::{AssertNonNullHandle, HandleToType};
20
21#[repr(C)]
25#[repr(align(4))] pub struct iox2_unique_subscriber_id_storage_t {
27 internal: [u8; 20], }
29
30#[repr(C)]
31#[iceoryx2_ffi(UniqueSubscriberId)]
32pub struct iox2_unique_subscriber_id_t {
33 pub value: iox2_unique_subscriber_id_storage_t,
34 pub(super) deleter: fn(*mut iox2_unique_subscriber_id_t),
35}
36
37impl iox2_unique_subscriber_id_t {
38 pub(super) fn init(
39 &mut self,
40 value: UniqueSubscriberId,
41 deleter: fn(*mut iox2_unique_subscriber_id_t),
42 ) {
43 self.value.init(value);
44 self.deleter = deleter;
45 }
46}
47
48pub struct iox2_unique_subscriber_id_h_t;
49pub type iox2_unique_subscriber_id_h = *mut iox2_unique_subscriber_id_h_t;
51pub type iox2_unique_subscriber_id_h_ref = *const iox2_unique_subscriber_id_h;
53
54impl AssertNonNullHandle for iox2_unique_subscriber_id_h {
55 fn assert_non_null(self) {
56 debug_assert!(!self.is_null());
57 }
58}
59
60impl AssertNonNullHandle for iox2_unique_subscriber_id_h_ref {
61 fn assert_non_null(self) {
62 debug_assert!(!self.is_null());
63 unsafe {
64 debug_assert!(!(*self).is_null());
65 }
66 }
67}
68
69impl HandleToType for iox2_unique_subscriber_id_h {
70 type Target = *mut iox2_unique_subscriber_id_t;
71
72 fn as_type(self) -> Self::Target {
73 self as *mut _ as _
74 }
75}
76
77impl HandleToType for iox2_unique_subscriber_id_h_ref {
78 type Target = *mut iox2_unique_subscriber_id_t;
79
80 fn as_type(self) -> Self::Target {
81 unsafe { *self as *mut _ as _ }
82 }
83}
84
85#[no_mangle]
99pub unsafe extern "C" fn iox2_unique_subscriber_id_drop(handle: iox2_unique_subscriber_id_h) {
100 debug_assert!(!handle.is_null());
101
102 let h = &mut *handle.as_type();
103 core::ptr::drop_in_place(h.value.as_option_mut());
104 (h.deleter)(h);
105}
106
107#[no_mangle]
114pub unsafe extern "C" fn iox2_unique_subscriber_id_eq(
115 lhs: iox2_unique_subscriber_id_h_ref,
116 rhs: iox2_unique_subscriber_id_h_ref,
117) -> bool {
118 lhs.assert_non_null();
119 rhs.assert_non_null();
120
121 let lhs = &mut *lhs.as_type();
122 let rhs = &mut *rhs.as_type();
123
124 lhs.value.as_ref() == rhs.value.as_ref()
125}
126
127#[no_mangle]
134pub unsafe extern "C" fn iox2_unique_subscriber_id_less(
135 lhs: iox2_unique_subscriber_id_h_ref,
136 rhs: iox2_unique_subscriber_id_h_ref,
137) -> bool {
138 lhs.assert_non_null();
139 rhs.assert_non_null();
140
141 let lhs = &mut *lhs.as_type();
142 let rhs = &mut *rhs.as_type();
143
144 lhs.value.as_ref() < rhs.value.as_ref()
145}
146
147