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
42398a54
Commit
42398a54
authored
5 years ago
by
Sébastien Blin
Committed by
Adrien Béraud
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
rust: infohash support == operator and from hex
parent
429a5ad1
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
rust/src/ffi.rs
+2
-0
2 additions, 0 deletions
rust/src/ffi.rs
rust/src/infohash.rs
+9
-0
9 additions, 0 deletions
rust/src/infohash.rs
rust/src/value.rs
+1
-1
1 addition, 1 deletion
rust/src/value.rs
with
12 additions
and
1 deletion
rust/src/ffi.rs
+
2
−
0
View file @
42398a54
...
@@ -44,6 +44,7 @@ pub struct Blob
...
@@ -44,6 +44,7 @@ pub struct Blob
}
}
#[repr(C)]
#[repr(C)]
#[derive(PartialEq)]
pub
struct
InfoHash
pub
struct
InfoHash
{
{
pub
d
:
[
u8
;
HASH_LEN
],
pub
d
:
[
u8
;
HASH_LEN
],
...
@@ -144,6 +145,7 @@ extern {
...
@@ -144,6 +145,7 @@ extern {
pub
fn
dht_infohash_print
(
h
:
*
const
InfoHash
)
->
*
const
c_char
;
pub
fn
dht_infohash_print
(
h
:
*
const
InfoHash
)
->
*
const
c_char
;
pub
fn
dht_infohash_random
(
h
:
*
mut
InfoHash
);
pub
fn
dht_infohash_random
(
h
:
*
mut
InfoHash
);
pub
fn
dht_infohash_get
(
h
:
*
mut
InfoHash
,
dat
:
*
mut
u8
,
dat_size
:
size_t
);
pub
fn
dht_infohash_get
(
h
:
*
mut
InfoHash
,
dat
:
*
mut
u8
,
dat_size
:
size_t
);
pub
fn
dht_infohash_from_hex
(
h
:
*
mut
InfoHash
,
dat
:
*
const
c_char
);
pub
fn
dht_infohash_is_zero
(
j
:
*
const
InfoHash
)
->
bool
;
pub
fn
dht_infohash_is_zero
(
j
:
*
const
InfoHash
)
->
bool
;
// dht::PkId
// dht::PkId
...
...
This diff is collapsed.
Click to expand it.
rust/src/infohash.rs
+
9
−
0
View file @
42398a54
...
@@ -55,6 +55,15 @@ impl InfoHash {
...
@@ -55,6 +55,15 @@ impl InfoHash {
h
h
}
}
pub
fn
from_hex
(
data
:
&
str
)
->
InfoHash
{
let
mut
h
=
InfoHash
::
new
();
unsafe
{
let
c_str
=
CString
::
new
(
data
)
.unwrap
();
dht_infohash_from_hex
(
&
mut
h
,
c_str
.as_ptr
());
}
h
}
pub
fn
is_zero
(
&
self
)
->
bool
{
pub
fn
is_zero
(
&
self
)
->
bool
{
unsafe
{
unsafe
{
dht_infohash_is_zero
(
self
)
dht_infohash_is_zero
(
self
)
...
...
This diff is collapsed.
Click to expand it.
rust/src/value.rs
+
1
−
1
View file @
42398a54
...
@@ -65,7 +65,7 @@ impl Value {
...
@@ -65,7 +65,7 @@ impl Value {
}
}
}
}
fn
recipient
(
&
self
)
->
InfoHash
{
pub
fn
recipient
(
&
self
)
->
InfoHash
{
unsafe
{
unsafe
{
dht_value_get_recipient
(
self
)
dht_value_get_recipient
(
self
)
}
}
...
...
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