Lines
0 %
Functions
use crate::commands::{
Command, GenericResponseValue, Request, RequestParserResult, ResponseAttributes,
ResponseParserError,
};
pub struct StickerTypes;
pub type StickerTypesResponse = Vec<String>;
impl Command for StickerTypes {
type Response = StickerTypesResponse;
const COMMAND: &'static str = "stickertypes";
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
debug_assert!(parts.next().is_none());
Ok((Request::StickerTypes, ""))
}
fn parse_response(
parts: ResponseAttributes<'_>,
) -> Result<Self::Response, ResponseParserError> {
debug_assert!(parts.0.iter().all(|(k, _)| *k == "stickertype"));
let list = parts
.0
.iter()
.map(|(_, v)| match v {
GenericResponseValue::Text(value) => Ok(value.to_string()),
GenericResponseValue::Binary(_) => Err(
ResponseParserError::UnexpectedPropertyType("stickertype", "Binary"),
),
})
.collect::<Result<Vec<_>, ResponseParserError>>()?;
Ok(list)