Skip to content

Commit

Permalink
fix clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status committed Nov 28, 2024
1 parent 1ad70f5 commit b8cf46a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions examples/basic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn main() -> Result<(), Error> {
// ========================================================================
// Setting an event callback to be executed each time a message is received
node2
.set_event_callback(&|response| {
.set_event_callback(|response| {
if let LibwakuResponse::Success(v) = response {
let event: Event =
serde_json::from_str(v.unwrap().as_str()).expect("Parsing event to succeed");
Expand All @@ -47,7 +47,7 @@ async fn main() -> Result<(), Error> {
.expect("set event call back working");

node1
.set_event_callback(&|response| {
.set_event_callback(|response| {
if let LibwakuResponse::Success(v) = response {
let event: Event =
serde_json::from_str(v.unwrap().as_str()).expect("Parsing event to succeed");
Expand Down
10 changes: 5 additions & 5 deletions waku-bindings/src/node/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ use std::sync::{Arc, Mutex};

use crate::utils::{get_trampoline, LibwakuResponse};

type LibwakuResponseClosure = dyn FnMut(LibwakuResponse) + Send + Sync;

pub struct WakuNodeContext {
obj_ptr: *mut c_void,
msg_observer: Arc<Mutex<Box<dyn FnMut(LibwakuResponse) + Send + Sync>>>,
msg_observer: Arc<Mutex<Box<LibwakuResponseClosure>>>,
}

impl WakuNodeContext {
pub fn new(obj_ptr: *mut c_void) -> Self {
let me = Self {
obj_ptr: obj_ptr,
obj_ptr,
msg_observer: Arc::new(Mutex::new(Box::new(|_| {}))),
};

Expand Down Expand Up @@ -54,9 +56,7 @@ impl WakuNodeContext {
};
Ok(())
} else {
Err(format!(
"Failed to acquire lock in waku_set_event_callback!"
))
Err("Failed to acquire lock in waku_set_event_callback!".to_string())
}
}
}
6 changes: 2 additions & 4 deletions waku-bindings/src/node/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ pub fn waku_filter_unsubscribe_all(ctx: &WakuNodeContext) -> Result<()> {
let code = unsafe {
let mut closure = result_cb;
let cb = get_trampoline(&closure);
let out = waku_sys::waku_filter_unsubscribe_all(
waku_sys::waku_filter_unsubscribe_all(
ctx.get_ptr(),
cb,
&mut closure as *mut _ as *mut c_void,
);

out
)
};

handle_no_response(code, result)
Expand Down

0 comments on commit b8cf46a

Please sign in to comment.