Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libxxdk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
elixxir
libxxdk
Commits
401c8be7
Commit
401c8be7
authored
Jul 5, 2024
by
Julia Andrews
Browse files
Options
Downloads
Patches
Plain Diff
Fix clippy warnings
parent
8493642f
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!9
Rust RPC module implementation
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
xxdk-rs/rpc-example/src/lib.rs
+5
-5
5 additions, 5 deletions
xxdk-rs/rpc-example/src/lib.rs
xxdk-rs/xxdk/src/base/callbacks.rs
+1
-0
1 addition, 0 deletions
xxdk-rs/xxdk/src/base/callbacks.rs
xxdk-rs/xxdk/src/rpc.rs
+10
-12
10 additions, 12 deletions
xxdk-rs/xxdk/src/rpc.rs
with
16 additions
and
17 deletions
xxdk-rs/rpc-example/src/lib.rs
+
5
−
5
View file @
401c8be7
use
std
::
fmt
::
Write
;
use
std
::
path
::
PathBuf
;
use
std
::
sync
::
Arc
;
...
...
@@ -60,11 +61,10 @@ pub async fn run() -> Result<(), String> {
}
pub
async
fn
xx_rpc_handler
(
_
:
Arc
<
CMix
>
,
request
:
IncomingRequest
)
->
Result
<
Vec
<
u8
>
,
String
>
{
let
sender
:
String
=
request
.sender_id
.iter
()
.map
(|
b
|
format!
(
"{b:02x}"
))
.collect
();
let
sender
:
String
=
request
.sender_id
.iter
()
.fold
(
String
::
new
(),
|
mut
s
,
b
|
{
write!
(
s
,
"{b:02x}"
)
.unwrap
();
s
});
tracing
::
info!
(
sender
,
"Received message via cMix"
,);
let
text
=
String
::
from_utf8_lossy
(
&
request
.request
);
...
...
...
...
This diff is collapsed.
Click to expand it.
xxdk-rs/xxdk/src/base/callbacks.rs
+
1
−
0
View file @
401c8be7
...
...
@@ -535,6 +535,7 @@ extern "C" fn cmix_rpc_send_error_cb(target: *mut c_void, err: *mut c_void, err_
pub
struct
RpcServerRequestHandler
{
pub
name
:
String
,
#[allow(clippy::type_complexity)]
pub
request_fn
:
Box
<
dyn
Fn
(
Vec
<
u8
>
,
Vec
<
u8
>
)
->
Vec
<
u8
>>
,
}
...
...
...
...
This diff is collapsed.
Click to expand it.
xxdk-rs/xxdk/src/rpc.rs
+
10
−
12
View file @
401c8be7
...
...
@@ -22,16 +22,14 @@ pub fn send(
bytes_as_go_slice
(
pubkey
),
bytes_as_go_slice
(
request
),
);
return
go_error_into_result
(
||
{
return
RpcResponse
{
go_error_into_result
(
||
RpcResponse
{
instance_id
:
r0
,
response_fn
:
None
,
error_fn
:
None
,
};
},
r1
,
)
;
)
}
}
...
...
@@ -53,7 +51,7 @@ pub fn generate_random_key(net: &CMix) -> Result<Vec<u8>, String> {
pub
fn
derive_public_key
(
private_key
:
&
[
u8
])
->
Result
<
Vec
<
u8
>
,
String
>
{
unsafe
{
let
prk
=
bytes_as_go_slice
(
&
private_key
);
let
prk
=
bytes_as_go_slice
(
private_key
);
let
cmix_rpc_derive_public_key_return
{
r0
,
r1
}
=
cmix_rpc_derive_public_key
(
prk
);
go_error_into_result
(||
c_byte_slice_into_vec
(
r0
),
r1
)
}
...
...
@@ -78,7 +76,7 @@ pub fn new_server<T: ServerCallback + 'static>(
let
srh
=
Box
::
new
(
RpcServerRequestHandler
{
request_fn
:
Box
::
new
(
move
|
sender_id
:
Vec
<
u8
>
,
request
:
Vec
<
u8
>
|
->
Vec
<
u8
>
{
tracing
::
debug!
(
"inside RpceServerRequestHandler closure"
);
return
request_callback
.serve_req
(
sender_id
,
request
)
;
request_callback
.serve_req
(
sender_id
,
request
)
}),
name
:
String
::
from
(
"new_server"
),
});
...
...
@@ -86,7 +84,7 @@ pub fn new_server<T: ServerCallback + 'static>(
unsafe
{
tracing
::
debug!
(
"new_server cb name: {}"
,
(
*
cb
)
.name
);
let
cb_obj
=
cb
as
*
const
_
as
*
const
c_void
as
usize
;
tracing
::
debug!
(
"new_server cb_obj {:#x}"
,
cb_obj
as
usize
);
tracing
::
debug!
(
"new_server cb_obj {:#x}"
,
cb_obj
);
let
cmix_rpc_new_server_return
{
r0
,
r1
}
=
cmix_rpc_new_server
(
net
.cmix_instance
,
cb_obj
,
...
...
@@ -110,7 +108,7 @@ pub fn load_server<T: ServerCallback + 'static>(
let
srh
=
Box
::
new
(
RpcServerRequestHandler
{
request_fn
:
Box
::
new
(
move
|
sender_id
:
Vec
<
u8
>
,
request
:
Vec
<
u8
>
|
->
Vec
<
u8
>
{
tracing
::
debug!
(
"inside RpceServerRequestHandler closure"
);
return
request_callback
.serve_req
(
sender_id
,
request
)
;
request_callback
.serve_req
(
sender_id
,
request
)
}),
name
:
String
::
from
(
"load_server"
),
});
...
...
...
...
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
sign in
to comment