1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
use serde::Deserialize; use serde::Serialize; use serde_json::value::Value as JsonValue; use crate::utils::str_or_u32; #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)] pub struct Phid(pub String); #[derive(Serialize, Deserialize, Debug)] pub struct Cursor { pub before: Option<String>, pub after: Option<String>, #[serde(deserialize_with = "str_or_u32")] pub limit: u32, pub order: Option<String>, } #[derive(Serialize, Debug, Default)] pub struct Search<A, C> { #[serde(rename = "queryKey")] pub query_key: Option<String>, pub constraints: C, pub attachments: A, } #[derive(Serialize, Debug)] pub struct SearchCursor<'a, A, C> { #[serde(flatten)] pub cursor: &'a Cursor, #[serde(flatten)] pub search: &'a Search<A, C>, } #[derive(Deserialize, Debug)] pub struct SearchData<A, F> { pub id: u32, #[serde(rename = "type")] pub ty: String, pub phid: Phid, pub fields: F, pub attachments: A, } #[derive(Deserialize, Debug)] pub struct SearchResult<A, F> { pub cursor: Cursor, pub data: Vec<SearchData<A, F>>, #[serde(flatten)] unparsed: JsonValue, }