Skip to content

Commit

Permalink
missed mut added
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Sep 12, 2024
1 parent c8c9dc5 commit db88076
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -1928,7 +1928,7 @@ const struct z_loaned_closure_sample_t *z_closure_sample_loan(const struct z_own
#if defined(UNSTABLE)
ZENOHC_API
void z_closure_zid_call(const struct z_loaned_closure_zid_t *closure,
const z_id_t *z_id);
z_id_t *z_id);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Expand Down Expand Up @@ -4797,7 +4797,7 @@ const struct zc_loaned_closure_log_t *zc_closure_log_loan(const struct zc_owned_
#if defined(UNSTABLE)
ZENOHC_API
void zc_closure_matching_status_call(const struct zc_loaned_closure_matching_status_t *closure,
const struct zc_matching_status_t *mathing_status);
struct zc_matching_status_t *mathing_status);
#endif
/**
* @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
Expand Down
8 changes: 4 additions & 4 deletions src/closures/matching_status_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub extern "C" fn zc_internal_closure_matching_status_check(
#[no_mangle]
pub extern "C" fn zc_closure_matching_status_call(
closure: &zc_loaned_closure_matching_status_t,
mathing_status: &zc_matching_status_t,
mathing_status: &mut zc_matching_status_t,
) {
let closure = closure.as_owned_c_type_ref();
match closure.call {
Expand All @@ -126,11 +126,11 @@ pub extern "C" fn zc_closure_matching_status_drop(
let _ = closure_.take_rust_type();
}

impl<F: Fn(&zc_matching_status_t)> From<F> for zc_owned_closure_matching_status_t {
impl<F: Fn(&mut zc_matching_status_t)> From<F> for zc_owned_closure_matching_status_t {
fn from(f: F) -> Self {
let this = Box::into_raw(Box::new(f)) as _;
extern "C" fn call<F: Fn(&zc_matching_status_t)>(
response: &zc_matching_status_t,
extern "C" fn call<F: Fn(&mut zc_matching_status_t)>(
response: &mut zc_matching_status_t,
this: *mut c_void,
) {
let this = unsafe { &*(this as *const F) };
Expand Down
6 changes: 3 additions & 3 deletions src/closures/zenohid_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub unsafe extern "C" fn z_internal_closure_zid_null(
/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release.
/// @brief Calls the closure. Calling an uninitialized closure is a no-op.
#[no_mangle]
pub extern "C" fn z_closure_zid_call(closure: &z_loaned_closure_zid_t, z_id: &z_id_t) {
pub extern "C" fn z_closure_zid_call(closure: &z_loaned_closure_zid_t, z_id: &mut z_id_t) {
let closure = closure.as_owned_c_type_ref();
match closure.call {
Some(call) => call(z_id, closure.context),
Expand All @@ -122,10 +122,10 @@ pub extern "C" fn z_closure_zid_drop(closure_: &mut z_moved_closure_zid_t) {
let _ = closure_.take_rust_type();
}

impl<F: Fn(&z_id_t)> From<F> for z_owned_closure_zid_t {
impl<F: Fn(&mut z_id_t)> From<F> for z_owned_closure_zid_t {
fn from(f: F) -> Self {
let this = Box::into_raw(Box::new(f)) as _;
extern "C" fn call<F: Fn(&z_id_t)>(response: &z_id_t, this: *mut c_void) {
extern "C" fn call<F: Fn(&mut z_id_t)>(response: &mut z_id_t, this: *mut c_void) {
let this = unsafe { &*(this as *const F) };
this(response)
}
Expand Down
8 changes: 4 additions & 4 deletions src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ pub unsafe extern "C" fn z_info_peers_zid(
) -> result::z_result_t {
let session = session.as_rust_type_ref();
let callback = callback.take_rust_type();
for id in session.info().peers_zid().wait() {
z_closure_zid_call(z_closure_zid_loan(&callback), id.as_ctype_ref());
for mut id in session.info().peers_zid().wait() {
z_closure_zid_call(z_closure_zid_loan(&callback), id.as_ctype_mut());
}
result::Z_OK
}
Expand All @@ -87,8 +87,8 @@ pub unsafe extern "C" fn z_info_routers_zid(
) -> result::z_result_t {
let session = session.as_rust_type_ref();
let callback = callback.take_rust_type();
for id in session.info().routers_zid().wait() {
z_closure_zid_call(z_closure_zid_loan(&callback), id.as_ctype_ref());
for mut id in session.info().routers_zid().wait() {
z_closure_zid_call(z_closure_zid_loan(&callback), id.as_ctype_mut());
}
result::Z_OK
}
8 changes: 4 additions & 4 deletions src/liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ pub extern "C" fn zc_liveliness_declare_subscriber(
.liveliness()
.declare_subscriber(key_expr)
.history(options.is_some_and(|o| o.history))
.callback(move |sample| {
let sample = sample.as_loaned_c_type_ref();
.callback(move |mut sample| {
let sample = sample.as_loaned_c_type_mut();
z_closure_sample_call(z_closure_sample_loan(&callback), sample)
})
.wait()
Expand Down Expand Up @@ -226,10 +226,10 @@ pub extern "C" fn zc_liveliness_get(
let key_expr = key_expr.as_rust_type_ref();
let callback = callback.take_rust_type();
let liveliness: Liveliness<'static> = session.liveliness();
let mut builder = liveliness.get(key_expr).callback(move |response| {
let mut builder = liveliness.get(key_expr).callback(move |mut response| {
z_closure_reply_call(
z_closure_reply_loan(&callback),
response.as_loaned_c_type_ref(),
response.as_loaned_c_type_mut(),
)
});
if let Some(options) = options {
Expand Down
4 changes: 2 additions & 2 deletions src/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ pub extern "C" fn zc_publisher_matching_listener_declare(
let listener = publisher
.matching_listener()
.callback_mut(move |matching_status| {
let status = zc_matching_status_t {
let mut status = zc_matching_status_t {
matching: matching_status.matching_subscribers(),
};
zc_closure_matching_status_call(zc_closure_matching_status_loan(&callback), &status);
zc_closure_matching_status_call(zc_closure_matching_status_loan(&callback), &mut status);
})
.wait();
match listener {
Expand Down
4 changes: 2 additions & 2 deletions src/querying_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ pub unsafe extern "C" fn ze_declare_querying_subscriber(
sub = sub.query_timeout(std::time::Duration::from_millis(options.query_timeout_ms));
}
}
let sub = sub.callback(move |sample| {
let sample = sample.as_loaned_c_type_ref();
let sub = sub.callback(move |mut sample| {
let sample = sample.as_loaned_c_type_mut();
z_closure_sample_call(z_closure_sample_loan(&callback), sample);
});
match sub.wait() {
Expand Down

0 comments on commit db88076

Please sign in to comment.