use serde::Serialize;
use crate::AnkiRequest;
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize)]
pub struct GetMediaDirPathRequest;
impl AnkiRequest for GetMediaDirPathRequest {
type Response = String;
const ACTION: &'static str = "getMediaDirPath";
const VERSION: u8 = 6;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_serialize() {
let request = GetMediaDirPathRequest;
let json = serde_json::to_string_pretty(&request).unwrap();
assert_eq!(json, "null");
}
#[test]
fn test_deserialize() {
let response: <GetMediaDirPathRequest as AnkiRequest>::Response =
serde_json::from_str("\"/home/user/.local/share/Anki2/Main/collection.media\"")
.unwrap();
assert_eq!(
response,
"/home/user/.local/share/Anki2/Main/collection.media".to_string()
);
}
}