pub enum ConsultationStatus {
Completed,
Timeout,
RateLimited,
AuthFailed,
Malformed,
Empty,
Unavailable,
Cancelled,
Error,
}Expand description
How a consultation ended, as the adapter classified it.
Only a completed consultation carries advice and counts as review; every other status
is a degradation that is recorded so the state can report it, never hidden. The wire
form is the snake_case word that ConsultationStatus::as_str returns.
use majordomus_cli::reasoning::record::ConsultationStatus;
let s: ConsultationStatus = serde_json::from_str("\"rate_limited\"").unwrap();
assert_eq!(s, ConsultationStatus::RateLimited);
assert!(!s.is_transient());
assert!(ConsultationStatus::Timeout.is_transient());Variants§
Completed
An answer was received and normalised.
Timeout
No answer within the time allowed.
RateLimited
The advisor refused for rate.
AuthFailed
The credential was refused.
Malformed
An answer arrived that could not be normalised.
Empty
An answer arrived with nothing in it.
The advisor could not be reached: not running, not answering, gone.
Cancelled
The session withdrew the request.
Error
Anything else the adapter could not classify.
Implementations§
Source§impl ConsultationStatus
impl ConsultationStatus
Sourcepub fn is_transient(self) -> bool
pub fn is_transient(self) -> bool
A failure that says the advisor may not be askable right now.
A timeout, an unreachable advisor and an unclassified error are transient: they count towards opening the advisor’s circuit. A refused credential, a rate limit or a malformed answer say something more specific and are not.
use majordomus_cli::reasoning::record::ConsultationStatus;
assert!(ConsultationStatus::Unavailable.is_transient());
assert!(!ConsultationStatus::Completed.is_transient());
assert!(!ConsultationStatus::AuthFailed.is_transient());Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
The status as the snake_case word the records and refusals spell it with.
It is the same word serde writes, so a refusal message and a stored record never disagree about how a status is named.
use majordomus_cli::reasoning::record::ConsultationStatus;
let s = ConsultationStatus::AuthFailed;
assert_eq!(s.as_str(), "auth_failed");
assert_eq!(serde_json::to_string(&s).unwrap(), format!("\"{}\"", s.as_str()));Trait Implementations§
Source§impl Clone for ConsultationStatus
impl Clone for ConsultationStatus
Source§fn clone(&self) -> ConsultationStatus
fn clone(&self) -> ConsultationStatus
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ConsultationStatus
Source§impl Debug for ConsultationStatus
impl Debug for ConsultationStatus
Source§impl<'de> Deserialize<'de> for ConsultationStatus
impl<'de> Deserialize<'de> for ConsultationStatus
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>,
impl Eq for ConsultationStatus
Source§impl Hash for ConsultationStatus
impl Hash for ConsultationStatus
Source§impl JsonSchema for ConsultationStatus
impl JsonSchema for ConsultationStatus
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 moreSource§impl Ord for ConsultationStatus
impl Ord for ConsultationStatus
Source§fn cmp(&self, other: &ConsultationStatus) -> Ordering
fn cmp(&self, other: &ConsultationStatus) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ConsultationStatus
impl PartialEq for ConsultationStatus
Source§fn eq(&self, other: &ConsultationStatus) -> bool
fn eq(&self, other: &ConsultationStatus) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ConsultationStatus
impl PartialOrd for ConsultationStatus
Source§impl Serialize for ConsultationStatus
impl Serialize for ConsultationStatus
impl StructuralPartialEq for ConsultationStatus
Auto Trait Implementations§
impl Freeze for ConsultationStatus
impl RefUnwindSafe for ConsultationStatus
impl Send for ConsultationStatus
impl Sync for ConsultationStatus
impl Unpin for ConsultationStatus
impl UnsafeUnpin for ConsultationStatus
impl UnwindSafe for ConsultationStatus
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.