Skip to main content

barcodefyi/
types.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Serialize, Deserialize)]
4pub struct SearchResult {
5    pub query: String,
6    pub results: Vec<SearchItem>,
7    pub total: usize,
8}
9
10#[derive(Debug, Serialize, Deserialize)]
11pub struct SearchItem {
12    pub name: String,
13    pub slug: String,
14    #[serde(rename = "type")]
15    pub item_type: String,
16}
17
18#[derive(Debug, Serialize, Deserialize)]
19pub struct SymbologyDetail {
20    pub name: String,
21    pub slug: String,
22    #[serde(flatten)]
23    pub extra: serde_json::Value,
24}
25
26#[derive(Debug, Serialize, Deserialize)]
27pub struct FamilyDetail {
28    pub name: String,
29    pub slug: String,
30    #[serde(flatten)]
31    pub extra: serde_json::Value,
32}
33
34#[derive(Debug, Serialize, Deserialize)]
35pub struct StandardDetail {
36    pub name: String,
37    pub slug: String,
38    #[serde(flatten)]
39    pub extra: serde_json::Value,
40}
41
42#[derive(Debug, Serialize, Deserialize)]
43pub struct ComponentDetail {
44    pub name: String,
45    pub slug: String,
46    #[serde(flatten)]
47    pub extra: serde_json::Value,
48}
49
50#[derive(Debug, Serialize, Deserialize)]
51pub struct GlossaryTerm {
52    pub name: String,
53    pub slug: String,
54    #[serde(flatten)]
55    pub extra: serde_json::Value,
56}
57
58#[derive(Debug, Serialize, Deserialize)]
59pub struct CompareResult {
60    #[serde(flatten)]
61    pub data: serde_json::Value,
62}
63
64#[derive(Debug, Serialize, Deserialize)]
65pub struct IndustryDetail {
66    pub name: String,
67    pub slug: String,
68    #[serde(flatten)]
69    pub extra: serde_json::Value,
70}
71
72#[derive(Debug, thiserror::Error)]
73pub enum BarcodeFyiError {
74    #[error("HTTP request failed: {0}")]
75    Http(#[from] reqwest::Error),
76    #[error("API error (HTTP {status}): {body}")]
77    Api { status: u16, body: String },
78}