Skip to content
Snippets Groups Projects
Commit 7212b7a2 authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud
Browse files

rust: change put api

parent 5c610895
No related branches found
No related tags found
No related merge requests found
......@@ -57,18 +57,16 @@ fn main() {
};
let ptr = &mut handler as *mut _ as *mut c_void;
println!("Start listening /foo");
let token = dht.listen(&InfoHash::get("foo"), value_cb, ptr);
thread::sleep(ten_secs);
println!("Stop listening /foo");
dht.cancel_listen(&InfoHash::get("foo"), token);
//println!("Start listening /foo");
//let token = dht.listen(&InfoHash::get("foo"), value_cb, ptr);
//thread::sleep(ten_secs);
//println!("Stop listening /foo");
//dht.cancel_listen(&InfoHash::get("foo"), token);
//loop {
println!("Get /alice");
dht.get(&InfoHash::get("alice"), get_cb, done_cb, ptr);
let v = Value::new("hi!");
// TODO put value
// TODO check drop
dht.put(&InfoHash::get("bob"), Box::into_raw(v), done_cb, ptr);
dht.put(&InfoHash::get("bob"), v, done_cb, ptr);
//thread::sleep(ten_secs);
//}
}
\ No newline at end of file
......@@ -112,12 +112,12 @@ impl DhtRunner {
}
}
pub fn put(&mut self, h: &InfoHash, v: *const Value,
pub fn put(&mut self, h: &InfoHash, v: Box<Value>,
done_cb: extern fn(bool, *mut c_void),
cb_user_data: *mut c_void) {
unsafe {
dht_runner_put(&mut *self, h, v, done_cb, cb_user_data)
dht_runner_put(&mut *self, h, &*v, done_cb, cb_user_data)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment