Lines
0 %
Functions
use crate::commands::{
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
expect_property_type,
};
pub struct StickerNames;
pub type StickerNamesResponse = Vec<String>;
impl Command for StickerNames {
type Response = StickerNamesResponse;
const COMMAND: &'static str = "stickernames";
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
debug_assert!(parts.next().is_none());
Ok((Request::StickerNames, ""))
}
fn parse_response(
parts: ResponseAttributes<'_>,
) -> Result<Self::Response, ResponseParserError> {
debug_assert!(parts.0.iter().all(|(k, _)| *k == "name"));
let list = parts
.0
.into_iter()
.map(|(k, v)| Ok(expect_property_type!(Some(v), k, Text).to_string()))
.collect::<Result<Vec<_>, ResponseParserError>>()?;
Ok(list)