QuickDID is a high-performance AT Protocol identity resolution service written in Rust. It provides handle-to-DID resolution with Redis-backed caching and queue processing.

refactor: error cleanup

+7 -7
+7 -7
src/handle_resolution_result.rs
··· 12 #[derive(Debug, Error)] 13 pub enum HandleResolutionError { 14 #[error("error-quickdid-resolution-1 System time error: {0}")] 15 - SystemTimeError(String), 16 17 #[error("error-quickdid-serialization-1 Failed to serialize resolution result: {0}")] 18 - SerializationError(String), 19 20 #[error("error-quickdid-serialization-2 Failed to deserialize resolution result: {0}")] 21 - DeserializationError(String), 22 } 23 24 /// Represents the type of DID method from a resolution ··· 51 pub fn success(did: &str) -> Result<Self, HandleResolutionError> { 52 let timestamp = SystemTime::now() 53 .duration_since(UNIX_EPOCH) 54 - .map_err(|e| HandleResolutionError::SystemTimeError(e.to_string()))? 55 .as_secs(); 56 57 let (method_type, payload) = Self::parse_did(did); ··· 67 pub fn not_resolved() -> Result<Self, HandleResolutionError> { 68 let timestamp = SystemTime::now() 69 .duration_since(UNIX_EPOCH) 70 - .map_err(|e| HandleResolutionError::SystemTimeError(e.to_string()))? 71 .as_secs(); 72 73 Ok(Self { ··· 105 /// Serialize the result to bytes using bincode 106 pub fn to_bytes(&self) -> Result<Vec<u8>, HandleResolutionError> { 107 bincode::serde::encode_to_vec(self, bincode::config::standard()) 108 - .map_err(|e| HandleResolutionError::SerializationError(e.to_string())) 109 } 110 111 /// Deserialize from bytes using bincode 112 pub fn from_bytes(bytes: &[u8]) -> Result<Self, HandleResolutionError> { 113 bincode::serde::decode_from_slice(bytes, bincode::config::standard()) 114 .map(|(result, _)| result) 115 - .map_err(|e| HandleResolutionError::DeserializationError(e.to_string())) 116 } 117 } 118
··· 12 #[derive(Debug, Error)] 13 pub enum HandleResolutionError { 14 #[error("error-quickdid-resolution-1 System time error: {0}")] 15 + SystemTime(String), 16 17 #[error("error-quickdid-serialization-1 Failed to serialize resolution result: {0}")] 18 + Serialization(String), 19 20 #[error("error-quickdid-serialization-2 Failed to deserialize resolution result: {0}")] 21 + Deserialization(String), 22 } 23 24 /// Represents the type of DID method from a resolution ··· 51 pub fn success(did: &str) -> Result<Self, HandleResolutionError> { 52 let timestamp = SystemTime::now() 53 .duration_since(UNIX_EPOCH) 54 + .map_err(|e| HandleResolutionError::SystemTime(e.to_string()))? 55 .as_secs(); 56 57 let (method_type, payload) = Self::parse_did(did); ··· 67 pub fn not_resolved() -> Result<Self, HandleResolutionError> { 68 let timestamp = SystemTime::now() 69 .duration_since(UNIX_EPOCH) 70 + .map_err(|e| HandleResolutionError::SystemTime(e.to_string()))? 71 .as_secs(); 72 73 Ok(Self { ··· 105 /// Serialize the result to bytes using bincode 106 pub fn to_bytes(&self) -> Result<Vec<u8>, HandleResolutionError> { 107 bincode::serde::encode_to_vec(self, bincode::config::standard()) 108 + .map_err(|e| HandleResolutionError::Serialization(e.to_string())) 109 } 110 111 /// Deserialize from bytes using bincode 112 pub fn from_bytes(bytes: &[u8]) -> Result<Self, HandleResolutionError> { 113 bincode::serde::decode_from_slice(bytes, bincode::config::standard()) 114 .map(|(result, _)| result) 115 + .map_err(|e| HandleResolutionError::Deserialization(e.to_string())) 116 } 117 } 118