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

rust: remove T for no. Anyway we must at least add None

parent 697d554e
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,7 @@ fn main() {
let mut put_done_cb = |ok: bool| {
println!("PUT: DONE CB - data: {} - ok: {}", data, ok);
};
dht.put(&InfoHash::get("bob"), Value::new("hi!"), &mut put_done_cb);
dht.put(&InfoHash::get("bob"), Value::new("hi!"), &mut put_done_cb, false);
println!("Start listening /foo");
......
......@@ -217,37 +217,37 @@ impl DhtRunner {
}
}
pub fn put<'a, T: Into<Option<bool>>>(&mut self, h: &InfoHash, v: Box<Value>,
done_cb: &'a mut(dyn FnMut(bool)), permanent: T) {
pub fn put<'a>(&mut self, h: &InfoHash, v: Box<Value>,
done_cb: &'a mut(dyn FnMut(bool)), permanent: bool) {
let handler = Box::new(PutHandler {
done_cb,
});
let handler = Box::into_raw(handler) as *mut c_void;
unsafe {
dht_runner_put(&mut *self, h, &*v, put_handler_done, handler, permanent.into().unwrap_or(false))
dht_runner_put(&mut *self, h, &*v, put_handler_done, handler, permanent)
}
}
pub fn put_signed<'a, T: Into<Option<bool>>>(&mut self, h: &InfoHash, v: Box<Value>,
done_cb: &'a mut(dyn FnMut(bool)), permanent: T) {
pub fn put_signed<'a>(&mut self, h: &InfoHash, v: Box<Value>,
done_cb: &'a mut(dyn FnMut(bool)), permanent: bool) {
let handler = Box::new(PutHandler {
done_cb,
});
let handler = Box::into_raw(handler) as *mut c_void;
unsafe {
dht_runner_put_signed(&mut *self, h, &*v, put_handler_done, handler, permanent.into().unwrap_or(false))
dht_runner_put_signed(&mut *self, h, &*v, put_handler_done, handler, permanent)
}
}
pub fn put_encrypted<'a, T: Into<Option<bool>>>(&mut self, h: &InfoHash, v: Box<Value>,
pub fn put_encrypted<'a>(&mut self, h: &InfoHash, v: Box<Value>,
to: &InfoHash,
done_cb: &'a mut(dyn FnMut(bool)), permanent: T) {
done_cb: &'a mut(dyn FnMut(bool)), permanent: bool) {
let handler = Box::new(PutHandler {
done_cb,
});
let handler = Box::into_raw(handler) as *mut c_void;
unsafe {
dht_runner_put_encrypted(&mut *self, h, &*v, to, put_handler_done, handler, permanent.into().unwrap_or(false))
dht_runner_put_encrypted(&mut *self, h, &*v, to, put_handler_done, handler, permanent)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment