pub struct Answer<T> {
pub contract: u32,
pub op: Op,
pub ok: bool,
pub result: Option<T>,
pub error: Option<String>,
pub code: Option<String>,
pub help: Option<String>,
pub limits: Vec<String>,
}Expand description
What an operation answers.
Fields§
§contract: u32The contract’s version (VERSION).
op: OpThe operation.
ok: boolWhether it passed: nothing found by a check, runs that agree, a game made, a toolchain complete. False too when it could not run.
result: Option<T>What it found or made; absent when it could not run.
error: Option<String>Why it could not run, if it could not.
code: Option<String>The problem code of its error (SH1002), or of its failure when
it ran and failed on the setup (doctor); shuyi explain <code>
prints its page.
help: Option<String>How to fix it, with the code.
limits: Vec<String>What it could not determine, in plain words.
Implementations§
Source§impl<T> Answer<T>
impl<T> Answer<T>
Sourcepub fn new(op: Op, ok: bool, result: T, limits: Vec<String>) -> Self
pub fn new(op: Op, ok: bool, result: T, limits: Vec<String>) -> Self
Operation op’s result, passed if ok, with limits.
Sourcepub fn failed(op: Op, code: Code, error: impl Into<String>) -> Self
pub fn failed(op: Op, code: Code, error: impl Into<String>) -> Self
Operation op, which could not run because of error, a problem
of code code, with its row’s help.
Sourcepub fn with_code(self, code: Code) -> Self
pub fn with_code(self, code: Code) -> Self
This answer with problem code code and its row’s help: for an
answer that ran and failed on the setup.
Sourcepub fn with_help(self, help: impl Into<String>) -> Self
pub fn with_help(self, help: impl Into<String>) -> Self
This answer with help instead of its code’s: a usage, or what
to fix first.
Sourcepub fn limited(self, limit: impl Into<String>) -> Self
pub fn limited(self, limit: impl Into<String>) -> Self
This answer with limit added to its limits.
Sourcepub fn exit_code(&self) -> u8
pub fn exit_code(&self) -> u8
The process exit code for it: 0 if it passed, else its code’s
class’s (codes::Class::exit_code), 1 with no code.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Answer<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Answer<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T> JsonSchema for Answer<T>where
T: JsonSchema,
impl<T> JsonSchema for Answer<T>where
T: JsonSchema,
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more