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;
7pub use crate::tls::TlsConfig;
8
9/// A single search hit, carrying its reference index so the inline body can
10/// cite `[N]` while the full URL lives in the reference block.
11#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
12pub struct SearchResult {
13    pub title: String,
14    pub snippet: String,
15    pub url: String,
16    pub ref_index: usize,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct SearchOutput {
21    pub query: String,
22    pub results: Vec<SearchResult>,
23    pub references: Vec<Reference>,
24    pub token_estimate: usize,
25    pub result_count: usize,
26}
27
28#[derive(Debug, Clone, Deserialize)]
29pub struct SearchOptions {
30    pub query: String,
31    pub max_results: Option<usize>,
32    pub safe_search: Option<bool>,
33    pub timeout_secs: u64,
34    /// TLS trust configuration (OS store is honoured by default; this carries
35    /// the explicit `--ca-cert` / `--insecure` overrides).
36    #[serde(default)]
37    pub tls: TlsConfig,
38}
39
40impl Default for SearchOptions {
41    fn default() -> Self {
42        Self {
43            query: String::new(),
44            max_results: Some(5),
45            safe_search: None,
46            timeout_secs: 10,
47            tls: TlsConfig::default(),
48        }
49    }
50}