36 lines
897 B
Rust
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 })
|
|
}
|
|
}
|