mindat_rs/models/
minerals_ima.rs1use serde::{Deserialize, Serialize};
4
5use super::serde_helpers::{deserialize_optional_vec_i32, deserialize_optional_vec_string};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct ImaMaterial {
10 pub id: i32,
12 #[serde(default)]
14 pub name: Option<String>,
15 #[serde(default)]
17 pub ima_formula: Option<String>,
18 #[serde(default)]
20 pub ima_symbol: Option<String>,
21 #[serde(default)]
23 pub ima_year: Option<String>,
24 #[serde(default)]
26 pub discovery_year: Option<String>,
27 #[serde(default, deserialize_with = "deserialize_optional_vec_string")]
29 pub ima_status: Option<Vec<String>>,
30 #[serde(default, deserialize_with = "deserialize_optional_vec_string")]
32 pub ima_notes: Option<Vec<String>>,
33 #[serde(default)]
35 pub type_specimen_store: Option<String>,
36 #[serde(default)]
38 pub mindat_longid: Option<String>,
39 #[serde(default)]
41 pub mindat_guid: Option<String>,
42 #[serde(default, deserialize_with = "deserialize_optional_vec_i32")]
44 pub type_localities: Option<Vec<i32>>,
45 #[serde(default)]
47 pub description_short: Option<String>,
48 #[serde(default)]
50 pub mindat_formula: Option<String>,
51 #[serde(default)]
53 pub mindat_formula_note: Option<String>,
54}
55
56#[derive(Debug, Clone, Default)]
58pub struct ImaMineralsQuery {
59 pub q: Option<String>,
61 pub ima: Option<i32>,
63 pub id_in: Option<Vec<i32>>,
65 pub updated_at: Option<String>,
67 pub fields: Option<String>,
69 pub omit: Option<String>,
71 pub expand: Option<Vec<String>>,
73 pub page: Option<i32>,
75 pub page_size: Option<i32>,
77}
78
79impl ImaMineralsQuery {
80 pub fn new() -> Self {
82 Self::default()
83 }
84
85 pub fn search(mut self, q: impl Into<String>) -> Self {
87 self.q = Some(q.into());
88 self
89 }
90
91 pub fn select_fields(mut self, fields: impl Into<String>) -> Self {
93 self.fields = Some(fields.into());
94 self
95 }
96
97 pub fn omit_fields(mut self, fields: impl Into<String>) -> Self {
99 self.omit = Some(fields.into());
100 self
101 }
102
103 pub fn expand_fields(mut self, fields: Vec<String>) -> Self {
105 self.expand = Some(fields);
106 self
107 }
108
109 pub fn page(mut self, page: i32) -> Self {
111 self.page = Some(page);
112 self
113 }
114
115 pub fn page_size(mut self, size: i32) -> Self {
117 self.page_size = Some(size);
118 self
119 }
120}