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/clientlogin.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/message/handshake/clientlogin.rs') diff --git a/src/message/handshake/clientlogin.rs b/src/message/handshake/clientlogin.rs index 4be4442..b1d9672 100644 --- a/src/message/handshake/clientlogin.rs +++ b/src/message/handshake/clientlogin.rs @@ -20,11 +20,19 @@ impl HandshakeSerialize for ClientLogin { } } -impl From for ClientLogin { - fn from(mut input: VariantMap) -> Self { - ClientLogin { - user: input.remove("User").unwrap().try_into().unwrap(), - password: input.remove("Password").unwrap().try_into().unwrap(), - } +impl TryFrom for ClientLogin { + type Error = ProtocolError; + + fn try_from(mut input: VariantMap) -> Result { + Ok(ClientLogin { + user: input + .remove("User") + .ok_or_else(|| ProtocolError::MissingField("User".to_string()))? + .try_into()?, + password: input + .remove("Password") + .ok_or_else(|| ProtocolError::MissingField("Password".to_string()))? + .try_into()?, + }) } } -- cgit v1.2.3