From cbf4e9d3826c47c360a7f4fa4dab55fe8ef4ab26 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 21 Nov 2025 15:14:43 +0900 Subject: [PATCH] commands: implement response parser for `protocol` --- src/commands/connection_settings/protocol.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/commands/connection_settings/protocol.rs b/src/commands/connection_settings/protocol.rs index 98232c35..95212cab 100644 --- a/src/commands/connection_settings/protocol.rs +++ b/src/commands/connection_settings/protocol.rs @@ -1,12 +1,13 @@ use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError}, + commands::{expect_property_type, Command, RequestParserResult, ResponseAttributes, ResponseParserError}, Request }; pub struct Protocol; +pub type ProtocolResponse = Vec; + impl Command for Protocol { - type Response = (); + type Response = ProtocolResponse; const COMMAND: &'static str = "protocol"; fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> { @@ -17,6 +18,16 @@ impl Command for Protocol { fn parse_response( parts: ResponseAttributes<'_>, ) -> Result> { - unimplemented!() + for (k, _) in parts.0.iter().filter(|(k, _)| *k != "feature") { + return Err(ResponseParserError::UnexpectedProperty(k)); + } + + let list = parts + .0 + .into_iter() + .map(|(k, v)| Ok(expect_property_type!(Some(v), k, Text).to_string())) + .collect::, ResponseParserError>>()?; + + Ok(list) } }