aboutsummaryrefslogtreecommitdiff
path: root/src/message/handshake/clientinitack.rs
diff options
context:
space:
mode:
authorMax Audron <me@audron.dev>2026-02-21 17:25:52 +0100
committerMax Audron <me@audron.dev>2026-02-21 17:25:52 +0100
commite63ecc10aa426e3aba416fd05a3f568d719a79a3 (patch)
treee1a8dc6e4197e51ddeb3d631410acec9eda3cf6a /src/message/handshake/clientinitack.rs
parentuse ProtocolError for From derive (diff)
handshare and signalproxy/rpccall error handling
Diffstat (limited to 'src/message/handshake/clientinitack.rs')
-rw-r--r--src/message/handshake/clientinitack.rs30
1 files changed, 22 insertions, 8 deletions
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<VariantMap> for ClientInitAck {
- fn from(input: VariantMap) -> Self {
- ClientInitAck {
+impl TryFrom<VariantMap> for ClientInitAck {
+ type Error = ProtocolError;
+
+ fn try_from(input: VariantMap) -> Result<Self, Self::Error> {
+ 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()?,
+ })
}
}