feat: update container

This commit is contained in:
2022-07-23 00:21:43 +08:00
parent 0415152500
commit a116b1c2e6
2 changed files with 139 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct FnResult {
error: Option<String>,
result: Option<String>,
}
impl FnResult {
pub fn fail(message: impl Into<String>) -> Self {
FnResult {
result: None,
error: Some(message.into()),
}
}
pub fn success(result: String) -> Self {
FnResult {
result: Some(result),
error: None,
}
}
pub fn to_json(&self) -> String {
serde_json::to_string(&self).expect("JSResult to json error")
}
}