commands: implement response parser for tagtypes available
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user