Example:
A very common way to answer a handle message is simply { "status": "success" } or { "status": "failure" }.
Every time we do that we have to write something along the lines of:
Ok(HandleResponse {
messages,
log: vec![],
data: Some(to_binary(&HandleAnswer::Send { status: Success })?),
})
For this we of course have to declare:
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum ResponseStatus {
Success,
Failure,
}
#[derive(Serialize, Deserialize, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum HandleAnswer {
Send {
status: ResponseStatus,
},
...
}
This is a lot of code and it's kind of annoying.
We should provide a standard implementation for common use cases that coders can use as a one-liner.
Example:
A very common way to answer a handle message is simply
{ "status": "success" }or{ "status": "failure" }.Every time we do that we have to write something along the lines of:
For this we of course have to declare:
This is a lot of code and it's kind of annoying.
We should provide a standard implementation for common use cases that coders can use as a one-liner.