Skip to main content

Diagnostic

Struct Diagnostic 

Source
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 str

The shape version of the JSON rendering.

§reason: Reason

One entry from the closed vocabulary.

§message: String

What 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

Source

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.

Source

pub fn expected(self, expected: impl Into<String>) -> Self

State what would have had to be true.

Source

pub fn action(self, action: impl Into<String>) -> Self

Name the command or change that fixes it.

Source

pub fn target_state(self, state: impl Into<String>) -> Self

State what the run left behind.

Source

pub fn step(self, step: impl Into<String>) -> Self

Name the step the failure happened in.

Source

pub fn run(self, run: impl Into<String>) -> Self

Name the run journal that explains the failure.

Source

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

Source§

fn clone(&self) -> Diagnostic

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Diagnostic

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for Diagnostic

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.