From e63ecc10aa426e3aba416fd05a3f568d719a79a3 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sat, 21 Feb 2026 17:25:52 +0100 Subject: handshare and signalproxy/rpccall error handling --- src/message/handshake/clientinitack.rs | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src/message/handshake/clientinitack.rs') diff --git a/src/message/handshake/clientinitack.rs b/src/message/handshake/clientinitack.rs index f3f4640..adb7425 100644 --- a/src/message/handshake/clientinitack.rs +++ b/src/message/handshake/clientinitack.rs @@ -45,16 +45,30 @@ impl HandshakeSerialize for ClientInitAck { } } -impl From for ClientInitAck { - fn from(input: VariantMap) -> Self { - ClientInitAck { +impl TryFrom for ClientInitAck { + type Error = ProtocolError; + + fn try_from(input: VariantMap) -> Result { + Ok(ClientInitAck { // TODO make this compatible with older clients core_features: 0, - core_configured: input.get("Configured").unwrap().try_into().unwrap(), - storage_backends: input.get("StorageBackends").unwrap().try_into().unwrap(), + core_configured: input + .get("Configured") + .ok_or_else(|| ProtocolError::MissingField("Configured".to_string()))? + .try_into()?, + storage_backends: input + .get("StorageBackends") + .ok_or_else(|| ProtocolError::MissingField("StorageBackends".to_string()))? + .try_into()?, #[cfg(feature = "authenticators")] - authenticators: input.get("Authenticators").unwrap().try_into().unwrap(), - feature_list: input.get("FeatureList").unwrap().try_into().unwrap(), - } + authenticators: input + .get("Authenticators") + .ok_or_else(|| ProtocolError::MissingField("Authenticators".to_string()))? + .try_into()?, + feature_list: input + .get("FeatureList") + .ok_or_else(|| ProtocolError::MissingField("FeatureList".to_string()))? + .try_into()?, + }) } } -- cgit v1.2.3