pub enum PeerFailureReason {
Timeout,
ConnectionFailed,
DataUnavailable,
CorruptedData,
ProtocolError,
Refused,
}Expand description
Categorizes why a peer interaction failed.
Used by consumers (like saorsa-node) to provide rich context when reporting failures to the trust/reputation system. Each variant carries a severity that the trust engine uses to weight the penalty.
§Example
use saorsa_core::error::PeerFailureReason;
let reason = PeerFailureReason::Timeout;
assert!(reason.is_transient());
assert!(reason.trust_severity() < 0.5);Variants§
Timeout
The peer did not respond within the expected time window.
ConnectionFailed
Could not establish or maintain a connection to the peer.
The peer was reachable but did not have the requested data.
CorruptedData
The peer returned data that failed integrity/hash verification.
ProtocolError
The peer violated the expected wire protocol.
Refused
The peer explicitly refused the request.
Implementations§
Source§impl PeerFailureReason
impl PeerFailureReason
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Whether this failure is transient (likely to succeed on retry).
Transient failures (timeout, connection issues) should not be penalized as heavily as persistent ones (corrupted data, protocol errors).
Sourcepub fn trust_severity(&self) -> f64
pub fn trust_severity(&self) -> f64
Trust severity score in the range [0.0, 1.0].
Higher values indicate more severe trust violations:
0.2— transient issues (timeout, connection)0.5— data unavailable / refused1.0— data corruption or protocol violation
Trait Implementations§
Source§impl Clone for PeerFailureReason
impl Clone for PeerFailureReason
Source§fn clone(&self) -> PeerFailureReason
fn clone(&self) -> PeerFailureReason
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PeerFailureReason
impl Debug for PeerFailureReason
Source§impl<'de> Deserialize<'de> for PeerFailureReason
impl<'de> Deserialize<'de> for PeerFailureReason
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>,
Source§impl Display for PeerFailureReason
impl Display for PeerFailureReason
Source§impl Hash for PeerFailureReason
impl Hash for PeerFailureReason
Source§impl PartialEq for PeerFailureReason
impl PartialEq for PeerFailureReason
Source§impl Serialize for PeerFailureReason
impl Serialize for PeerFailureReason
impl Copy for PeerFailureReason
impl Eq for PeerFailureReason
impl StructuralPartialEq for PeerFailureReason
Auto Trait Implementations§
impl Freeze for PeerFailureReason
impl RefUnwindSafe for PeerFailureReason
impl Send for PeerFailureReason
impl Sync for PeerFailureReason
impl Unpin for PeerFailureReason
impl UnsafeUnpin for PeerFailureReason
impl UnwindSafe for PeerFailureReason
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt 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.Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.