pub struct Diagnostic {
pub schema: &'static str,
pub reason: Reason,
pub message: String,
pub expected: Option<String>,
pub action: Option<String>,
pub retry: Option<bool>,
pub target_state: Option<String>,
pub step: Option<String>,
pub run: Option<String>,
}Expand description
One failure, with its parts named.
A hint that is not known is omitted rather than invented, so every optional field serializes only when present.
Fields§
§schema: &'static strThe shape version of the JSON rendering.
reason: ReasonOne entry from the closed vocabulary.
message: StringWhat happened, one line.
expected: Option<String>What would have had to be true.
action: Option<String>The exact command or change that fixes it, when known.
retry: Option<bool>Whether rerunning as-is can succeed.
target_state: Option<String>What the run left behind, stated plainly.
step: Option<String>The step it happened in, where there is one.
run: Option<String>The run journal explaining it, where one was written.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn new(reason: Reason, message: impl Into<String>) -> Self
pub fn new(reason: Reason, message: impl Into<String>) -> Self
A diagnostic carrying only its reason and message; the builder methods add what is actually known.
Sourcepub fn expected(self, expected: impl Into<String>) -> Self
pub fn expected(self, expected: impl Into<String>) -> Self
State what would have had to be true.
Sourcepub fn action(self, action: impl Into<String>) -> Self
pub fn action(self, action: impl Into<String>) -> Self
Name the command or change that fixes it.
Sourcepub fn target_state(self, state: impl Into<String>) -> Self
pub fn target_state(self, state: impl Into<String>) -> Self
State what the run left behind.
Sourcepub fn run(self, run: impl Into<String>) -> Self
pub fn run(self, run: impl Into<String>) -> Self
Name the run journal that explains the failure.
Sourcepub fn render_human(&self) -> String
pub fn render_human(&self) -> String
The human rendering: the five questions in order — what happened, what was expected, what to do, how to resume, what state the target is in — with unknown lines absent rather than invented.
Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more