add getsubset request helper
This commit is contained in:
parent
cdaf2fb259
commit
a02db1606a
|
@ -11,6 +11,7 @@ const MAX_RPC_BODY_LEN: usize = 65536;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ApiMethod {
|
pub enum ApiMethod {
|
||||||
|
GetSubset,
|
||||||
Publish,
|
Publish,
|
||||||
WhoAmI,
|
WhoAmI,
|
||||||
Get,
|
Get,
|
||||||
|
@ -25,6 +26,7 @@ impl ApiMethod {
|
||||||
pub fn selector(&self) -> &'static [&'static str] {
|
pub fn selector(&self) -> &'static [&'static str] {
|
||||||
use ApiMethod::*;
|
use ApiMethod::*;
|
||||||
match self {
|
match self {
|
||||||
|
GetSubset => &["partialReplication", "getSubset"],
|
||||||
Publish => &["publish"],
|
Publish => &["publish"],
|
||||||
WhoAmI => &["whoami"],
|
WhoAmI => &["whoami"],
|
||||||
Get => &["get"],
|
Get => &["get"],
|
||||||
|
@ -38,6 +40,7 @@ impl ApiMethod {
|
||||||
pub fn from_selector(s: &[&str]) -> Option<Self> {
|
pub fn from_selector(s: &[&str]) -> Option<Self> {
|
||||||
use ApiMethod::*;
|
use ApiMethod::*;
|
||||||
match s {
|
match s {
|
||||||
|
["partialReplication", "getSubset"] => Some(GetSubset),
|
||||||
["publish"] => Some(Publish),
|
["publish"] => Some(Publish),
|
||||||
["whoami"] => Some(WhoAmI),
|
["whoami"] => Some(WhoAmI),
|
||||||
["get"] => Some(Get),
|
["get"] => Some(Get),
|
||||||
|
@ -68,6 +71,15 @@ impl<W: Write + Unpin> ApiCaller<W> {
|
||||||
&mut self.rpc
|
&mut self.rpc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Send ["partialReplication", "getSubset"] request.
|
||||||
|
pub async fn getsubset_req_send(&mut self, query: SubsetQuery) -> Result<RequestNo> {
|
||||||
|
let req_no = self
|
||||||
|
.rpc
|
||||||
|
.send_request(ApiMethod::GetSubset.selector(), RpcType::Source, &query)
|
||||||
|
.await?;
|
||||||
|
Ok(req_no)
|
||||||
|
}
|
||||||
|
|
||||||
/// Send ["publish"] request.
|
/// Send ["publish"] request.
|
||||||
pub async fn publish_req_send(&mut self, msg: TypedMessage) -> Result<RequestNo> {
|
pub async fn publish_req_send(&mut self, msg: TypedMessage) -> Result<RequestNo> {
|
||||||
let req_no = self
|
let req_no = self
|
||||||
|
|
Loading…
Reference in New Issue