error.rs (2324B)
1 use alloc::string::String; 2 use core::fmt; 3 4 #[derive(Debug, Clone, PartialEq, Eq)] 5 pub enum RadrootsSimplexAgentStoreError { 6 ConnectionNotFound(String), 7 QueueNotFound(String), 8 CommandNotFound(u64), 9 MissingPrimarySendQueue(String), 10 PendingOutboundMessage(String), 11 StagedOutboundMessageMissing(String), 12 StagedOutboundMessageMismatch { 13 connection_id: String, 14 expected: u64, 15 actual: u64, 16 }, 17 QueueAuthStateMissing(String), 18 Persistence(String), 19 } 20 21 impl fmt::Display for RadrootsSimplexAgentStoreError { 22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 23 match self { 24 Self::ConnectionNotFound(id) => write!(f, "SimpleX agent connection `{id}` not found"), 25 Self::QueueNotFound(id) => write!(f, "SimpleX agent queue `{id}` not found"), 26 Self::CommandNotFound(id) => write!(f, "SimpleX agent command `{id}` not found"), 27 Self::MissingPrimarySendQueue(id) => { 28 write!( 29 f, 30 "SimpleX agent connection `{id}` has no primary send queue" 31 ) 32 } 33 Self::PendingOutboundMessage(id) => { 34 write!( 35 f, 36 "SimpleX agent connection `{id}` already has a staged outbound message" 37 ) 38 } 39 Self::StagedOutboundMessageMissing(id) => { 40 write!( 41 f, 42 "SimpleX agent connection `{id}` has no staged outbound message" 43 ) 44 } 45 Self::StagedOutboundMessageMismatch { 46 connection_id, 47 expected, 48 actual, 49 } => { 50 write!( 51 f, 52 "SimpleX agent connection `{connection_id}` staged outbound message mismatch: expected `{expected}`, got `{actual}`" 53 ) 54 } 55 Self::QueueAuthStateMissing(id) => { 56 write!( 57 f, 58 "SimpleX agent queue `{id}` is missing transport auth state" 59 ) 60 } 61 Self::Persistence(message) => write!(f, "{message}"), 62 } 63 } 64 } 65 66 #[cfg(feature = "std")] 67 impl std::error::Error for RadrootsSimplexAgentStoreError {}