add two constructors

This commit is contained in:
vms 2021-02-19 17:45:27 +03:00
parent b7274974f7
commit 517b13e1ac

View File

@ -35,3 +35,29 @@ pub struct MountedBinaryResult {
/// there was an error.
pub result: String,
}
impl MountedBinaryResult {
/// Create a new success MountedBinaryResult from the provided result.
pub fn success(result: String) -> Self {
let ret_code = SUCCESS_CODE;
let error_message = String::new();
Self {
ret_code,
error_message,
result,
}
}
/// Create a new failure MountedBinaryResult from the provided ret_code and error_message.
pub fn error(ret_code: i32, error_message: impl Into<String>) -> Self {
let error_message = error_message.into();
let result = String::new();
Self {
ret_code,
error_message,
result,
}
}
}