Lines
0 %
Functions
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::{
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
response_tokenizer::{ResponseAttributes, get_and_parse_property, get_property},
};
pub struct Config;
empty_command_request!(Config, "config");
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ConfigResponse {
pub music_directory: String,
pub playlist_directory: String,
pub pcre: bool,
}
impl ConfigResponse {
pub fn new(music_directory: String, playlist_directory: String, pcre: bool) -> Self {
ConfigResponse {
music_directory,
playlist_directory,
pcre,
impl CommandResponse for ConfigResponse {
fn into_response_enum(self) -> crate::Response {
todo!()
fn from_response_enum(_response: crate::Response) -> Option<Self> {
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
let parts: HashMap<_, _> = parts.into_map()?;
let music_directory = get_property!(parts, "music_directory", Text).to_string();
let playlist_directory = get_property!(parts, "playlist_directory", Text).to_string();
// TODO: is this parsed correctly?
let pcre = get_and_parse_property!(parts, "pcre", Text);
Ok(ConfigResponse {
})
impl Command for Config {
type Request = ConfigRequest;
type Response = ConfigResponse;