Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
7212b7a2
Commit
7212b7a2
authored
Oct 17, 2019
by
Sébastien Blin
Committed by
Adrien Béraud
Oct 22, 2019
Browse files
Options
Downloads
Patches
Plain Diff
rust: change put api
parent
5c610895
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rust/examples/dhtnode.rs
+6
-8
6 additions, 8 deletions
rust/examples/dhtnode.rs
rust/src/lib.rs
+2
-2
2 additions, 2 deletions
rust/src/lib.rs
with
8 additions
and
10 deletions
rust/examples/dhtnode.rs
+
6
−
8
View file @
7212b7a2
...
...
@@ -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
This diff is collapsed.
Click to expand it.
rust/src/lib.rs
+
2
−
2
View file @
7212b7a2
...
...
@@ -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
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment