mirror of
https://github.com/fluencelabs/marine-rs-sdk
synced 2025-03-15 06:20:50 +00:00
add into_std
This commit is contained in:
parent
210fd72b89
commit
292bdc73ea
@ -48,4 +48,16 @@ impl Result {
|
||||
stderr: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// This function checks ret_code and returns either Ok if it was SUCCESS_CODE or Err otherwise.
|
||||
///
|
||||
/// SAFETY:
|
||||
/// The function relies on both stdout and stderr to contain valid UTF8 string.
|
||||
unsafe fn into_std(self) -> std::result::Result<String, String> {
|
||||
if self.ret_code == SUCCESS_CODE {
|
||||
Ok(String::from_utf8_unchecked(self.stdout))
|
||||
} else {
|
||||
Err(String::from_utf8_unchecked(self.stderr))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user