Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33308967
D4945.1768803426.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D4945.1768803426.diff
View Options
diff --git a/services/backup/blob_client/src/lib.rs b/services/backup/blob_client/src/lib.rs
--- a/services/backup/blob_client/src/lib.rs
+++ b/services/backup/blob_client/src/lib.rs
@@ -6,13 +6,15 @@
put_client_blocking_read_cxx, put_client_initialize_cxx,
put_client_terminate_cxx, put_client_write_cxx,
};
-
#[cxx::bridge]
mod ffi {
extern "Rust" {
- fn put_client_initialize_cxx() -> ();
- unsafe fn put_client_write_cxx(data: *const c_char) -> ();
- fn put_client_blocking_read_cxx() -> ();
- fn put_client_terminate_cxx() -> ();
+ fn put_client_initialize_cxx() -> Result<()>;
+ unsafe fn put_client_write_cxx(
+ field_index: usize,
+ data: *const c_char,
+ ) -> Result<()>;
+ fn put_client_blocking_read_cxx() -> Result<String>;
+ fn put_client_terminate_cxx() -> Result<()>;
}
}
diff --git a/services/backup/blob_client/src/put_client.rs b/services/backup/blob_client/src/put_client.rs
--- a/services/backup/blob_client/src/put_client.rs
+++ b/services/backup/blob_client/src/put_client.rs
@@ -59,7 +59,7 @@
}
}
-pub fn put_client_initialize_cxx() -> () {
+pub fn put_client_initialize_cxx() -> Result<(), String> {
println!("[RUST] initializing");
assert!(!is_initialized(), "client cannot be initialized twice");
// spawn transmitter thread
@@ -92,9 +92,12 @@
CLIENT.lock().expect("access client").rx_handle = Some(rx_handle);
CLIENT.lock().expect("access client").rx = Some(receiver_thread_rx);
println!("[RUST] initialized");
+ Ok(())
}
-pub fn put_client_blocking_read_cxx() -> () {
+pub fn put_client_blocking_read_cxx() -> Result<String, String> {
+ let mut response: Option<String> = None;
+ check_error()?;
RUNTIME.block_on(async {
let mut rx: mpsc::Receiver<String> = CLIENT
.lock()
@@ -104,13 +107,22 @@
.expect("access client's receiver");
if let Some(data) = rx.recv().await {
println!("received data {}", data);
+ response = Some(data);
}
CLIENT.lock().expect("access client").rx = Some(rx);
});
+ if response.is_none() {
+ return Err("response not received properly".to_string());
+ }
+ Ok(response.unwrap())
}
-pub fn put_client_write_cxx(data: *const c_char) -> () {
+pub fn put_client_write_cxx(
+ field_index: usize,
+ data: *const c_char,
+) -> Result<(), String> {
println!("[RUST] [put_client_process] begin");
+ check_error()?;
let data_c_str: &CStr = unsafe { CStr::from_ptr(data) };
let data_str: String = data_c_str.to_str().unwrap().to_owned();
println!("[RUST] [put_client_process] data string: {}", data_str);
@@ -127,9 +139,11 @@
.expect("send data to receiver");
});
println!("[RUST] [put_client_process] end");
+ Ok(())
}
-pub fn put_client_terminate_cxx() -> () {
+pub fn put_client_terminate_cxx() -> Result<(), String> {
+ check_error()?;
println!("[RUST] put_client_terminating");
let tx_handle = CLIENT
.lock()
@@ -155,4 +169,6 @@
"client transmitter handler released properly"
);
println!("[RUST] put_client_terminated");
+ check_error()?;
+ Ok(())
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 6:17 AM (16 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5954784
Default Alt Text
D4945.1768803426.diff (3 KB)
Attached To
Mode
D4945: [DRAFT] [services] Backup - Connect to Blob - Use Result
Attached
Detach File
Event Timeline
Log In to Comment