pub enum M2MError {
Show 23 variants
Compression(String),
Decompression(String),
InvalidCodec(String),
Protocol(String),
NegotiationFailed(String),
SessionNotEstablished,
SessionExpired,
InvalidMessage(String),
CapabilityMismatch(String),
ModelNotLoaded(String),
ModelNotFound(String),
Tokenizer(String),
Config(String),
Json(Error),
Network(String),
Upstream(String),
Server(String),
Inference(String),
ModelLoad(String),
Io(Error),
Crypto(CryptoError),
SecurityThreat {
threat_type: String,
confidence: f32,
},
ContentBlocked(String),
}Expand description
M2M Protocol errors, organized by epistemic category.
See module documentation for the full epistemic taxonomy.
Variants§
Compression(String)
Compression failed due to invalid input or unsupported content.
Epistemic: B_i falsified — caller believed content was compressible.
Decompression(String)
Decompression failed due to corrupted or invalid wire format.
Epistemic: B_i falsified — caller believed data was valid M2M format.
InvalidCodec(String)
Codec identifier not recognized or not supported.
Epistemic: B_i falsified — caller believed codec was available.
Protocol(String)
Protocol state machine violation.
Epistemic: B_i falsified — caller believed operation was valid in current state.
NegotiationFailed(String)
Session handshake failed to agree on capabilities.
Epistemic: B_i falsified — caller believed negotiation would succeed.
SessionNotEstablished
Operation requires an established session, but session is not ready.
Epistemic: B_i falsified — caller believed session was established.
SessionExpired
Session has exceeded its timeout duration.
Epistemic: B_i falsified — caller believed session was still valid.
InvalidMessage(String)
Message does not conform to expected format.
Epistemic: B_i falsified — caller believed message was well-formed.
CapabilityMismatch(String)
Peers have incompatible capabilities for the requested operation.
Epistemic: B_i falsified — caller believed capabilities were compatible.
ModelNotLoaded(String)
ML model was expected to be loaded but isn’t.
Epistemic: B_i falsified — caller believed model was available.
ModelNotFound(String)
Requested model not found in the registry.
Epistemic: B_i falsified — caller believed model existed.
Tokenizer(String)
Tokenizer operation failed (invalid encoding, unknown token).
Epistemic: B_i falsified — caller believed input was tokenizable.
Config(String)
Configuration is invalid or missing required values.
Epistemic: B_i falsified — caller believed config was valid.
Json(Error)
JSON serialization/deserialization failed.
Epistemic: B_i falsified — caller believed data was valid JSON.
Network(String)
Network operation failed (connection, timeout, DNS).
Epistemic: I^B materialized — network availability was unknown until we attempted the operation.
Handling: Retry with exponential backoff, circuit breaker.
Upstream(String)
Upstream service returned an error or is unavailable.
Epistemic: I^B materialized — upstream health was unknown until we made the request.
Handling: Retry, failover to alternate upstream, degrade gracefully.
Server(String)
Server-side processing error.
Epistemic: I^B materialized — server state was unknown to client.
Inference(String)
ML inference failed during execution.
Epistemic: I^B materialized — model execution success depends on input characteristics and runtime state.
ModelLoad(String)
Failed to load ML model from filesystem or network.
Epistemic: I^B materialized — model file availability unknown until load attempted.
Io(Error)
I/O operation failed.
Epistemic: I^B materialized — filesystem/resource state unknown until operation attempted.
Crypto(CryptoError)
Cryptographic operation failed (key derivation, encryption, auth).
Epistemic: Mixed — may be B_i (invalid key) or I^B (RNG failure).
The inner CryptoError provides specific classification.
This variant preserves the full error chain via #[source],
enabling tools like anyhow to display complete context.
SecurityThreat
Security scanner detected a threat in content.
Epistemic: B_i falsified — content was believed to be safe.
Handling: Do NOT retry, log for security audit, consider blocking source.
Fields
ContentBlocked(String)
Content blocked by security policy.
Epistemic: B_i falsified — content was believed to comply with policy.
Handling: Do NOT retry, inform user of policy violation.
Implementations§
Source§impl M2MError
impl M2MError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if this error is retryable.
I^B errors (network, upstream, inference) are generally retryable. B_i errors (validation failures) are NOT retryable without changes.
§Example
match operation() {
Err(e) if e.is_retryable() => retry_with_backoff(operation),
Err(e) => return Err(e),
Ok(v) => v,
}Sourcepub fn is_security_error(&self) -> bool
pub fn is_security_error(&self) -> bool
Returns true if this error is security-related.
Security errors should NOT be retried and may warrant special logging.
Sourcepub fn is_bounded_ignorance(&self) -> bool
pub fn is_bounded_ignorance(&self) -> bool
Returns true if this error indicates bounded ignorance (I^B).
These errors stem from external system state that was unknown at compile time.
Sourcepub fn is_belief_falsified(&self) -> bool
pub fn is_belief_falsified(&self) -> bool
Returns true if this error indicates a falsified belief (B_i).
These errors indicate the caller made an incorrect assumption about input validity or system state.
Trait Implementations§
Source§impl Error for M2MError
impl Error for M2MError
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
Source§impl From<CryptoError> for M2MError
impl From<CryptoError> for M2MError
Source§fn from(err: CryptoError) -> Self
fn from(err: CryptoError) -> Self
Source§impl From<DecodeError> for M2MError
impl From<DecodeError> for M2MError
Source§fn from(err: DecodeError) -> Self
fn from(err: DecodeError) -> Self
Auto Trait Implementations§
impl Freeze for M2MError
impl !RefUnwindSafe for M2MError
impl Send for M2MError
impl Sync for M2MError
impl Unpin for M2MError
impl !UnwindSafe for M2MError
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> 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> 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
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§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.