pub struct Rejection {
pub code: String,
pub error: String,
pub expected: Option<String>,
pub actual: Option<String>,
pub next: String,
}Expand description
A refusal, with enough for a client to decide what to do next.
Fields§
§code: StringStable machine-readable reason.
error: StringHuman-readable detail. Kept named error because that is what
every existing client and test already reads.
expected: Option<String>What the check required, when the check compared two states.
actual: Option<String>What it found instead.
next: StringThe admissible next action, in the imperative. This is the field the research isolates the gain to, so it is required rather than optional: a rejection that cannot name a next action is a rejection whose author has not finished thinking.
Implementations§
Source§impl Rejection
impl Rejection
Sourcepub fn new(
code: Code,
error: impl Into<String>,
next: impl Into<String>,
) -> Self
pub fn new( code: Code, error: impl Into<String>, next: impl Into<String>, ) -> Self
A rejection with no state comparison.
Sourcepub fn with_states(
self,
expected: Option<String>,
actual: Option<String>,
) -> Self
pub fn with_states( self, expected: Option<String>, actual: Option<String>, ) -> Self
Adds the two states a failed comparison was between.
Sourcepub fn decode(reason: &str) -> Self
pub fn decode(reason: &str) -> Self
Recovers a rejection from a reason string.
A reason that did not come from Rejection::encode becomes an
Code::Unclassified rejection carrying the original text, so a
caller always gets the same shape and no message is ever dropped
on the floor.