1use macros::make_path_parts;
4use serde::{Deserialize, Serialize};
5use strum_macros::EnumIter;
6
7make_path_parts!(CreateSearchKeyPath => "/v1/search/key");
8
9#[derive(Serialize, Deserialize, Debug, Clone)]
11pub struct CreateSearchKeyResponse {
12 pub key: String,
14 }
16
17make_path_parts!(WebImageSearchPath => "/v1/search/web/image");
18
19#[derive(Serialize, Deserialize, Clone, Debug, Default)]
21#[serde(rename_all = "camelCase")]
22pub struct WebImageSearchQuery {
23 #[serde(default)]
25 pub q: String,
26
27 #[serde(skip_serializing_if = "Option::is_none")]
29 pub image_type: Option<ImageType>,
30}
31
32#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, EnumIter)]
34#[serde(rename_all = "camelCase")]
35pub enum ImageType {
36 Clipart = 0,
38 AnimatedGif = 1,
40 Photo = 2,
42 Line = 3,
44 Transparent = 4,
46}
47
48impl ImageType {
50 #[must_use]
52 pub fn to_str(self) -> &'static str {
53 match self {
54 Self::Clipart => "Clipart",
55 Self::AnimatedGif => "AnimatedGif",
56 Self::Photo => "Photo",
57 Self::Line => "Line",
58 Self::Transparent => "Transparent",
59 }
60 }
61}
62
63#[derive(Serialize, Deserialize, Debug, Clone)]
65pub struct WebImageSearchItem {
66 pub thumbnail_url: url::Url,
68 pub url: url::Url,
70}
71
72#[derive(Serialize, Deserialize, Debug)]
75pub struct WebImageSearchResponse {
76 pub images: Vec<WebImageSearchItem>,
78}