Page MenuHomePhabricator

D5034.diff
No OneTemporary

D5034.diff

diff --git a/services/backup/blob_client/src/tools.rs b/services/backup/blob_client/src/tools.rs
--- a/services/backup/blob_client/src/tools.rs
+++ b/services/backup/blob_client/src/tools.rs
@@ -1,3 +1,5 @@
+use libc::c_char;
+use std::ffi::{CStr, CString};
use std::sync::{Arc, Mutex};
use tracing::error;
@@ -17,7 +19,9 @@
error!("could not access error messages");
}
-pub fn check_error(error_messages: &Arc<Mutex<Vec<String>>>) -> Result<(), String> {
+pub fn check_error(
+ error_messages: &Arc<Mutex<Vec<String>>>,
+) -> Result<(), String> {
if let Ok(errors) = error_messages.lock() {
return match errors.is_empty() {
true => Ok(()),
@@ -26,3 +30,23 @@
}
Err("could not access error messages".to_string())
}
+
+pub fn c_char_pointer_to_string(
+ c_char_pointer: *const c_char,
+) -> Result<String, String> {
+ let holder_cstr: &CStr = unsafe { CStr::from_ptr(c_char_pointer) };
+ match holder_cstr.to_str() {
+ Ok(result) => Ok(result.to_owned()),
+ Err(err) => Err(err.to_string()),
+ }
+}
+
+pub fn string_to_c_char_pointer(
+ signs: &String,
+) -> Result<*const c_char, String> {
+ let cstr = CString::new((&signs).as_bytes());
+ match cstr {
+ Ok(result) => Ok(result.as_ptr()),
+ Err(err) => Err(err.to_string()),
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 1:34 AM (18 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2567145
Default Alt Text
D5034.diff (1 KB)

Event Timeline