Skip to main content

browsr_types/
search.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4/// Response from the /v1/search endpoint.
5#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
6#[serde(rename_all = "camelCase")]
7pub struct SearchResponse {
8    pub success: bool,
9    pub total: usize,
10    pub data: Vec<SearchResultEntry>,
11}
12
13/// A single search result entry from /v1/search.
14#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
15#[serde(rename_all = "camelCase")]
16pub struct SearchResultEntry {
17    pub url: String,
18    pub title: String,
19    pub description: String,
20    pub position: usize,
21    #[serde(default, skip_serializing_if = "Option::is_none")]
22    pub content: Option<serde_json::Value>,
23}
24
25#[derive(Serialize, Deserialize, Debug, Default, JsonSchema, Clone)]
26pub struct SearchOptions {
27    pub query: String,
28    #[serde(default, skip_serializing_if = "Option::is_none")]
29    pub limit: Option<usize>,
30}