helpers for solar
This commit is contained in:
parent
4994495781
commit
3ee2aa2a9d
|
@ -1,5 +1,5 @@
|
|||
use crate::feed::Message;
|
||||
use crate::rpc::{BodyType, RequestNo, RpcStream, RpcType};
|
||||
use crate::rpc::{Body,BodyType, RequestNo, RpcStream, RpcType};
|
||||
use async_std::io::{Read, Write};
|
||||
use serde_json;
|
||||
|
||||
|
@ -245,6 +245,10 @@ impl ApiMethod {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
pub fn from_rpc_body(body : &Body) -> Option<Self> {
|
||||
let selector = body.name.iter().map(|v| v.as_str()).collect::<Vec<_>>();
|
||||
Self::from_selector(&selector)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ApiHelper<R: Read + Unpin, W: Write + Unpin> {
|
||||
|
|
|
@ -52,7 +52,7 @@ impl AsRef<[u8]> for MessageId {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct Message {
|
||||
pub value: serde_json::Value,
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub enum BodyType {
|
|||
JSON,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Debug,Deserialize)]
|
||||
pub struct Body {
|
||||
pub name: Vec<String>,
|
||||
#[serde(rename = "type")]
|
||||
|
@ -127,6 +127,7 @@ pub struct RpcStream<R: io::Read + Unpin, W: io::Write + Unpin> {
|
|||
req_no: RequestNo,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum RecvMsg {
|
||||
RpcRequest(Body),
|
||||
RpcResponse(BodyType, Vec<u8>),
|
||||
|
|
Loading…
Reference in New Issue