Skip to main content

websearch/
types.rs

1//! Types for the web-search layer.
2
3use serde::{Deserialize, Serialize};
4
5/// The slim reference entry shared with the fetch path.
6pub use crate::refs::Reference;
7
8/// A single search hit, carrying its reference index so the inline body can
9/// cite `[N]` while the full URL lives in the reference block.
10#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
11pub struct SearchResult {
12    pub title: String,
13    pub snippet: String,
14    pub url: String,
15    pub ref_index: usize,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct SearchOutput {
20    pub query: String,
21    pub results: Vec<SearchResult>,
22    pub references: Vec<Reference>,
23    pub token_estimate: usize,
24    pub result_count: usize,
25}
26
27#[derive(Debug, Clone, Deserialize)]
28pub struct SearchOptions {
29    pub query: String,
30    pub max_results: Option<usize>,
31    pub safe_search: Option<bool>,
32    pub timeout_secs: u64,
33}
34
35impl Default for SearchOptions {
36    fn default() -> Self {
37        Self {
38            query: String::new(),
39            max_results: Some(5),
40            safe_search: None,
41            timeout_secs: 10,
42        }
43    }
44}