1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct TrekOptions {
10 pub debug: bool,
12
13 pub url: Option<String>,
15
16 #[serde(flatten)]
18 pub output: OutputOptions,
19
20 #[serde(flatten)]
22 pub removal: RemovalOptions,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(rename_all = "camelCase")]
28pub struct OutputOptions {
29 pub markdown: bool,
31
32 pub separate_markdown: bool,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(rename_all = "camelCase")]
39pub struct RemovalOptions {
40 pub remove_exact_selectors: bool,
42
43 pub remove_partial_selectors: bool,
45}
46
47impl Default for TrekOptions {
48 fn default() -> Self {
49 Self {
50 debug: false,
51 url: None,
52 output: OutputOptions {
53 markdown: false,
54 separate_markdown: false,
55 },
56 removal: RemovalOptions {
57 remove_exact_selectors: true,
58 remove_partial_selectors: true,
59 },
60 }
61 }
62}
63
64#[derive(Debug, Clone, Default, Serialize, Deserialize)]
66#[serde(rename_all = "camelCase")]
67pub struct TrekMetadata {
68 pub title: String,
70
71 pub description: String,
73
74 pub domain: String,
76
77 pub favicon: String,
79
80 pub image: String,
82
83 pub parse_time: u64,
85
86 pub published: String,
88
89 pub author: String,
91
92 pub site: String,
94
95 pub schema_org_data: Vec<serde_json::Value>,
97
98 pub word_count: usize,
100
101 pub mini_app_embed: Option<MiniAppEmbed>,
103}
104
105#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(rename_all = "camelCase")]
108pub struct MetaTagItem {
109 pub name: Option<String>,
111
112 pub property: Option<String>,
114
115 pub content: String,
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(rename_all = "camelCase")]
122pub struct TrekResponse {
123 pub content: String,
125
126 pub content_markdown: Option<String>,
128
129 pub extractor_type: Option<String>,
131
132 pub meta_tags: Vec<MetaTagItem>,
134
135 #[serde(flatten)]
137 pub metadata: TrekMetadata,
138}
139
140pub type ExtractorVariables = HashMap<String, String>;
142
143#[derive(Debug, Clone, Default)]
145pub struct ExtractedContent {
146 pub title: Option<String>,
148
149 pub author: Option<String>,
151
152 pub published: Option<String>,
154
155 pub content: Option<String>,
157
158 pub content_html: Option<String>,
160
161 pub variables: Option<ExtractorVariables>,
163}
164
165#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
167#[serde(rename_all = "snake_case")]
168pub enum MiniAppActionType {
169 LaunchFrame,
170 ViewToken,
171}
172
173#[derive(Debug, Clone, Serialize, Deserialize)]
175#[serde(rename_all = "camelCase")]
176pub struct MiniAppAction {
177 #[serde(rename = "type")]
179 pub action_type: MiniAppActionType,
180
181 pub url: Option<String>,
183
184 pub name: Option<String>,
186
187 pub splash_image_url: Option<String>,
189
190 pub splash_background_color: Option<String>,
192}
193
194#[derive(Debug, Clone, Serialize, Deserialize)]
196#[serde(rename_all = "camelCase")]
197pub struct MiniAppButton {
198 pub title: String,
200
201 pub action: MiniAppAction,
203}
204
205#[derive(Debug, Clone, Serialize, Deserialize)]
207#[serde(rename_all = "camelCase")]
208pub struct MiniAppEmbed {
209 pub version: String,
211
212 pub image_url: String,
214
215 pub button: MiniAppButton,
217}