Vendor asic-rs 0.8.1 (280 crates, offline builds) + wxWidgets 3.3.3 (pristine + patch queue); UI spec + ADR-0003; M1 on asic-rs
This commit is contained in:
+55
@@ -0,0 +1,55 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::errors::RPCError;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum MinerCommand {
|
||||
RPC {
|
||||
command: &'static str,
|
||||
parameters: Option<Value>,
|
||||
},
|
||||
GRPC {
|
||||
command: &'static str,
|
||||
},
|
||||
WebAPI {
|
||||
command: &'static str,
|
||||
parameters: Option<Value>,
|
||||
},
|
||||
GraphQL {
|
||||
command: &'static str,
|
||||
},
|
||||
SSH {
|
||||
command: &'static str,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum RPCCommandStatus {
|
||||
Success,
|
||||
Information,
|
||||
Error(String),
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl RPCCommandStatus {
|
||||
pub fn into_result(self) -> Result<(), RPCError> {
|
||||
match self {
|
||||
RPCCommandStatus::Success => Ok(()),
|
||||
RPCCommandStatus::Information => Ok(()),
|
||||
RPCCommandStatus::Error(msg) => Err(RPCError::StatusCheckFailed(msg)),
|
||||
RPCCommandStatus::Unknown => {
|
||||
Err(RPCError::StatusCheckFailed(String::from("Unknown status")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_str(response: &str, message: Option<&str>) -> Self {
|
||||
match response {
|
||||
"S" => RPCCommandStatus::Success,
|
||||
"I" => RPCCommandStatus::Information,
|
||||
"E" => RPCCommandStatus::Error(message.unwrap_or("Unknown error").to_string()),
|
||||
_ => RPCCommandStatus::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user