use crate::{search::*, util::*};
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(remote = "Self")]
pub struct WrapperQuery {
query: String,
}
impl Query {
pub fn wrapper<S>(query: S) -> WrapperQuery
where
S: ToString,
{
WrapperQuery {
query: query.to_string(),
}
}
}
impl ShouldSkip for WrapperQuery {}
serialize_with_root!("wrapper": WrapperQuery);
deserialize_with_root!("wrapper": WrapperQuery);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn serialization() {
assert_serialize_query(
Query::wrapper("eyJ0ZXJtIiA6IHsgInVzZXIuaWQiIDogImtpbWNoeSIgfX0="),
json!({ "wrapper": { "query": "eyJ0ZXJtIiA6IHsgInVzZXIuaWQiIDogImtpbWNoeSIgfX0=" } }),
);
}
}