pub struct ObjectiveEvalError { /* private fields */ }Expand description
A failed objective evaluation, classified by the producer.
§Why this carries a typed source
The classification must be made once, by the code that knows what
failed, and then travel unchanged. Before this type carried a
source, the boundary was lossy: a caller with a rich typed error in
hand had to render it to a String to cross into opt, and any
layer that later needed to re-classify the same failure had nothing
left to consult but the prose. That can produce a real defect: one
error variant may be classified recoverable at the site that can
still see its type and fatal at the site that could only see its
text, so a trial the optimizer is equipped to survive aborts the
entire run. The verdict was carried in prose, and prose
is one format! away from silently changing meaning.
recoverable_from and
fatal_from attach the originating error so
downstream code can downcast_ref back to it
instead of re-deriving a classification that was already made.
Implementations§
Source§impl ObjectiveEvalError
impl ObjectiveEvalError
Sourcepub fn recoverable(message: impl Into<String>) -> ObjectiveEvalError
pub fn recoverable(message: impl Into<String>) -> ObjectiveEvalError
A recoverable failure described only by a message.
Sourcepub fn fatal(message: impl Into<String>) -> ObjectiveEvalError
pub fn fatal(message: impl Into<String>) -> ObjectiveEvalError
A fatal failure described only by a message.
Sourcepub fn from_source<E>(kind: ObjectiveEvalKind, source: E) -> ObjectiveEvalError
pub fn from_source<E>(kind: ObjectiveEvalKind, source: E) -> ObjectiveEvalError
A failure of the given kind carrying the originating typed error.
The message is the source’s Display; the source itself stays
reachable via source_ref /
downcast_ref so no later layer has to
reconstruct the classification from text.
Sourcepub fn recoverable_from<E>(source: E) -> ObjectiveEvalError
pub fn recoverable_from<E>(source: E) -> ObjectiveEvalError
Sourcepub fn fatal_from<E>(source: E) -> ObjectiveEvalError
pub fn fatal_from<E>(source: E) -> ObjectiveEvalError
Sourcepub fn with_context(self, context: impl Display) -> ObjectiveEvalError
pub fn with_context(self, context: impl Display) -> ObjectiveEvalError
Prefix the message, preserving the kind and the typed source.
Use this instead of format!-ing the rendered error into a new
ObjectiveEvalError: re-wrapping through a string is exactly
what loses the classification.
Sourcepub fn kind(&self) -> ObjectiveEvalKind
pub fn kind(&self) -> ObjectiveEvalKind
The producer’s classification.
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
true when the solver may back off and continue.
Sourcepub fn into_message(self) -> String
pub fn into_message(self) -> String
Consume the error and take its message.
Sourcepub fn source_ref(&self) -> Option<&(dyn Error + Send + Sync + 'static)>
pub fn source_ref(&self) -> Option<&(dyn Error + Send + Sync + 'static)>
The originating error, when one was attached.
Sourcepub fn downcast_ref<E>(&self) -> Option<&E>
pub fn downcast_ref<E>(&self) -> Option<&E>
Recover the producer’s own error type.
This is the mechanism that lets a classification be carried rather than re-derived: a layer that needs to know what failed asks for the type back instead of pattern-matching the prose.
Trait Implementations§
Source§impl Clone for ObjectiveEvalError
impl Clone for ObjectiveEvalError
Source§fn clone(&self) -> ObjectiveEvalError
fn clone(&self) -> ObjectiveEvalError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ObjectiveEvalError
impl Debug for ObjectiveEvalError
Source§impl Display for ObjectiveEvalError
impl Display for ObjectiveEvalError
Source§impl Error for ObjectiveEvalError
impl Error for ObjectiveEvalError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for ObjectiveEvalError
impl !UnwindSafe for ObjectiveEvalError
impl Freeze for ObjectiveEvalError
impl Send for ObjectiveEvalError
impl Sync for ObjectiveEvalError
impl Unpin for ObjectiveEvalError
impl UnsafeUnpin for ObjectiveEvalError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.