wallhaven_rs/models/response/search.rs
1mod query;
2mod tag_query;
3mod wallpaper_summary;
4
5pub use query::*;
6use serde::Deserialize;
7use serde_with::{DisplayFromStr, PickFirst, serde_as};
8pub use tag_query::*;
9pub use wallpaper_summary::*;
10
11/// Search results, see properties for more information
12#[derive(Deserialize, Clone, Debug)]
13pub struct SearchResult {
14 /// The actual found wallpapers
15 pub data: Vec<WallpaperSummary>,
16 /// Pagination/Query metadata
17 pub meta: Meta,
18}
19
20/// Meta informations for the search results, used mostly to continue the search
21#[serde_as]
22#[derive(Deserialize, Clone, Debug)]
23pub struct Meta {
24 /// The current page
25 pub current_page: u64,
26 /// The last page (e.g. page count)
27 pub last_page: u64,
28
29 #[serde_as(as = "PickFirst<(DisplayFromStr, _)>")]
30 /// How many wallpapers per page
31 pub per_page: u64,
32 /// Total wallpapers count
33 ///
34 /// Meaning every page, except the last, will have `total` wallpapers, you can know how many there are in the last by doing:
35 /// `(last_page * per_page) - total`
36 pub total: u64,
37 /// The query information, see [`Query`] variants for more informations
38 pub query: Option<Query>,
39 /// Random seed used when using `SortingType::Random`
40 ///
41 /// This can be fed back into the search request to not repeat wallpapers
42 pub seed: Option<String>,
43}