|
15 | 15 | use super::common::types::z_protocol_id_t; |
16 | 16 | use crate::{ |
17 | 17 | errors::{z_error_t, Z_EINVAL, Z_OK}, |
18 | | - transmute::{LoanedCTypeRef, RustTypeRef, RustTypeRefUninit}, |
19 | | - z_loaned_shm_client_storage_t, z_moved_shm_client_storage_t, z_owned_shm_client_storage_t, |
20 | | - z_owned_shm_client_t, zc_loaned_shm_client_list_t, zc_moved_shm_client_list_t, |
21 | | - zc_owned_shm_client_list_t, |
| 18 | + transmute::{IntoRustType, LoanedCTypeRef, RustTypeRef, RustTypeRefUninit}, |
| 19 | + z_loaned_shm_client_storage_t, z_moved_shm_client_storage_t, z_moved_shm_client_t, |
| 20 | + z_owned_shm_client_storage_t, z_owned_shm_client_t, zc_loaned_shm_client_list_t, |
| 21 | + zc_moved_shm_client_list_t, zc_owned_shm_client_list_t, |
22 | 22 | }; |
23 | 23 | use std::{mem::MaybeUninit, sync::Arc}; |
24 | 24 | use zenoh::shm::{ProtocolID, ShmClient, ShmClientStorage, GLOBAL_CLIENT_STORAGE}; |
25 | 25 |
|
26 | 26 | decl_c_type!( |
27 | | - owned( |
28 | | - zc_owned_shm_client_list_t, |
29 | | - Option<Vec<(ProtocolID, Arc<dyn ShmClient>)>>, |
30 | | - ), |
31 | | - loaned(zc_loaned_shm_client_list_t, Vec<(ProtocolID, Arc<dyn ShmClient>)>), |
32 | | -moved(zc_moved_shm_client_list_t) |
| 27 | + owned(zc_owned_shm_client_list_t, option Vec<(ProtocolID, Arc<dyn ShmClient>)>), |
| 28 | + loaned(zc_loaned_shm_client_list_t), |
| 29 | + moved(zc_moved_shm_client_list_t) |
33 | 30 | ); |
34 | 31 |
|
35 | 32 | /// Creates a new empty list of SHM Clients |
@@ -86,25 +83,20 @@ pub unsafe extern "C" fn zc_shm_client_list_loan_mut( |
86 | 83 | #[no_mangle] |
87 | 84 | pub extern "C" fn zc_shm_client_list_add_client( |
88 | 85 | id: z_protocol_id_t, |
89 | | - client: &mut z_owned_shm_client_t, |
| 86 | + client: z_moved_shm_client_t, |
90 | 87 | list: &mut zc_loaned_shm_client_list_t, |
91 | 88 | ) -> z_error_t { |
92 | | - match client.as_rust_type_mut().take() { |
93 | | - Some(client) => { |
94 | | - list.as_rust_type_mut().push((id, client)); |
95 | | - Z_OK |
96 | | - } |
97 | | - None => Z_EINVAL, |
98 | | - } |
| 89 | + let Some(client) = client.into_rust_type() else { |
| 90 | + return Z_EINVAL; |
| 91 | + }; |
| 92 | + list.as_rust_type_mut().push((id, client)); |
| 93 | + Z_OK |
99 | 94 | } |
100 | 95 |
|
101 | 96 | decl_c_type!( |
102 | | - owned( |
103 | | - z_owned_shm_client_storage_t, |
104 | | - Option<Arc<ShmClientStorage>>, |
105 | | - ), |
106 | | - loaned(z_loaned_shm_client_storage_t, Arc<ShmClientStorage>), |
107 | | -moved(z_moved_shm_client_storage_t) |
| 97 | + owned(z_owned_shm_client_storage_t, option Arc<ShmClientStorage> ), |
| 98 | + loaned(z_loaned_shm_client_storage_t), |
| 99 | + moved(z_moved_shm_client_storage_t) |
108 | 100 | ); |
109 | 101 |
|
110 | 102 | #[no_mangle] |
|
0 commit comments