56d7c942db
This also exposes all the command types as public API
42 lines
1015 B
Rust
42 lines
1015 B
Rust
use std::collections::HashMap;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::{
|
|
commands::{
|
|
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
|
},
|
|
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
|
types::Uri,
|
|
};
|
|
|
|
pub struct Rescan;
|
|
|
|
single_optional_item_command_request!(Rescan, "rescan", Uri);
|
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
pub struct RescanResponse {
|
|
pub updating_db: usize,
|
|
}
|
|
|
|
impl RescanResponse {
|
|
pub fn new(updating_db: usize) -> Self {
|
|
RescanResponse { updating_db }
|
|
}
|
|
}
|
|
|
|
impl CommandResponse for RescanResponse {
|
|
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
|
let parts: HashMap<_, _> = parts.into_map()?;
|
|
|
|
let updating_db = get_and_parse_property!(parts, "updating_db", Text);
|
|
|
|
Ok(RescanResponse { updating_db })
|
|
}
|
|
}
|
|
|
|
impl Command for Rescan {
|
|
type Request = RescanRequest;
|
|
type Response = RescanResponse;
|
|
}
|