|
|
|
@ -28,6 +28,8 @@ pub enum ErrorCode {
@@ -28,6 +28,8 @@ pub enum ErrorCode {
|
|
|
|
|
NoPermission = 107, |
|
|
|
|
NotFound = 109, |
|
|
|
|
// NotUnique = 110,
|
|
|
|
|
NoSuchSection = 120, |
|
|
|
|
NoSuchSectionRun = 121, |
|
|
|
|
Internal = 200, |
|
|
|
|
NotImplemented = 201, |
|
|
|
|
Timeout = 300, |
|
|
|
@ -156,20 +158,24 @@ impl RequestError {
@@ -156,20 +158,24 @@ impl RequestError {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)] |
|
|
|
|
struct ResponseMessage(#[serde(rename = "message")] String); |
|
|
|
|
struct ResponseMessage { |
|
|
|
|
message: String, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl ResponseMessage { |
|
|
|
|
fn new<M>(message: M) -> Self |
|
|
|
|
where |
|
|
|
|
M: ToString, |
|
|
|
|
{ |
|
|
|
|
ResponseMessage(message.to_string()) |
|
|
|
|
ResponseMessage { |
|
|
|
|
message: message.to_string(), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl From<String> for ResponseMessage { |
|
|
|
|
fn from(message: String) -> Self { |
|
|
|
|
ResponseMessage(message) |
|
|
|
|
ResponseMessage { message } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -213,13 +219,6 @@ where
@@ -213,13 +219,6 @@ where
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)] |
|
|
|
|
#[serde(rename_all = "camelCase", tag = "type")] |
|
|
|
|
pub enum Request { |
|
|
|
|
RunSection(sections::RunSectionRequest), |
|
|
|
|
CancelSection(sections::CancelSectionRequest), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)] |
|
|
|
|
#[serde(rename_all = "camelCase", tag = "result")] |
|
|
|
|
pub enum Response { |
|
|
|
@ -242,6 +241,24 @@ impl From<RequestError> for Response {
@@ -242,6 +241,24 @@ impl From<RequestError> for Response {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)] |
|
|
|
|
#[serde(rename_all = "camelCase")] |
|
|
|
|
pub struct WithRequestId<T> { |
|
|
|
|
pub rid: i32, |
|
|
|
|
#[serde(flatten)] |
|
|
|
|
pub rest: T, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub type ResponseWithId = WithRequestId<Response>; |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)] |
|
|
|
|
#[serde(rename_all = "camelCase", tag = "type")] |
|
|
|
|
pub enum Request { |
|
|
|
|
RunSection(sections::RunSectionRequest), |
|
|
|
|
CancelSection(sections::CancelSectionRequest), |
|
|
|
|
CancelSectionRunId(sections::CancelSectionRunIdRequest), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl IRequest for Request { |
|
|
|
|
type Response = ResponseValue; |
|
|
|
|
|
|
|
|
@ -249,6 +266,7 @@ impl IRequest for Request {
@@ -249,6 +266,7 @@ impl IRequest for Request {
|
|
|
|
|
match self { |
|
|
|
|
Request::RunSection(req) => req.exec_erased(ctx), |
|
|
|
|
Request::CancelSection(req) => req.exec_erased(ctx), |
|
|
|
|
Request::CancelSectionRunId(req) => req.exec_erased(ctx), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -258,13 +276,3 @@ impl Request {
@@ -258,13 +276,3 @@ impl Request {
|
|
|
|
|
self.exec(ctx).map(Response::from) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize, Serialize)] |
|
|
|
|
#[serde(rename_all = "camelCase")] |
|
|
|
|
pub struct WithRequestId<T> { |
|
|
|
|
pub rid: i32, |
|
|
|
|
#[serde(flatten)] |
|
|
|
|
pub rest: T, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub type ResponseWithId = WithRequestId<Response>; |
|
|
|
|