commands: implement response parser for tagtypes available

This commit is contained in:
2025-11-21 15:16:30 +09:00
parent 10913fd48c
commit d09ca013d5

View File

@@ -1,12 +1,13 @@
use crate::{
Request,
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
commands::{expect_property_type, Command, RequestParserResult, ResponseAttributes, ResponseParserError}, Request
};
pub struct TagTypesAvailable;
pub type TagTypesAvailableResponse = Vec<String>;
impl Command for TagTypesAvailable {
type Response = ();
type Response = TagTypesAvailableResponse;
const COMMAND: &'static str = "tagtypes available";
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
@@ -17,6 +18,19 @@ impl Command for TagTypesAvailable {
fn parse_response(
parts: ResponseAttributes<'_>,
) -> Result<Self::Response, ResponseParserError<'_>> {
unimplemented!()
let parts: Vec<_> = parts.into();
let mut tagtypes = Vec::with_capacity(parts.len());
for (key, value) in parts.into_iter() {
if key != "tagtype" {
return Err(ResponseParserError::UnexpectedProperty(key));
}
let tagtype = expect_property_type!(Some(value), "tagtype", Text).to_string();
tagtypes.push(tagtype);
}
Ok(tagtypes)
}
}