Files
empidee/src/commands/music_database/rescan.rs
h7x4 e910d29aa4
Some checks failed
Build and test / build (push) Successful in 59s
Build and test / check (push) Failing after 1m2s
Build and test / test (push) Successful in 1m42s
Build and test / docs (push) Successful in 1m19s
Rust edition 2024
2025-02-26 16:39:34 +01:00

36 lines
897 B
Rust

use std::collections::HashMap;
use crate::commands::{
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
get_and_parse_property,
};
pub struct Rescan;
pub struct RescanResponse {
pub updating_db: usize,
}
impl Command for Rescan {
type Response = RescanResponse;
const COMMAND: &'static str = "rescan";
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
let uri = parts.next().map(|s| s.to_string());
debug_assert!(parts.next().is_none());
Ok((Request::Rescan(uri), ""))
}
fn parse_response(
parts: ResponseAttributes<'_>,
) -> Result<Self::Response, ResponseParserError> {
let parts: HashMap<_, _> = parts.into();
let updating_db = get_and_parse_property!(parts, "updating_db", Text);
Ok(RescanResponse { updating_db })
}
}