#[non_exhaustive]pub enum SearchBackend {
Brave(BraveSearchProvider),
}Expand description
Concrete backend dispatch.
An enum (not Box<dyn ErasedSearchProvider>) keeps WebSearchExecutor
non-generic and avoids erased-async-trait boilerplate for a small, closed backend set.
New backends are new variants.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Brave(BraveSearchProvider)
Brave Search API (v1 default backend).
Implementations§
Source§impl SearchBackend
impl SearchBackend
Sourcepub fn from_config(
cfg: &SearchConfig,
max_body_bytes: usize,
api_key: Option<Secret>,
) -> Result<Self, SearchError>
pub fn from_config( cfg: &SearchConfig, max_body_bytes: usize, api_key: Option<Secret>, ) -> Result<Self, SearchError>
Resolve a backend from config plus an optional pre-fetched API key.
max_body_bytes caps the response body size a provider will read (from
[tools.scrape].max_body_bytes — the search tool has no independent body-size
config, mirroring its denied_domains/ipi_filter_threshold inheritance).
Returns Err for a keyed backend (e.g. Brave) with no key. A future keyless
backend (e.g. SearXNG) must be constructible with api_key: None — callers gate
tool availability on this function’s success, not on “key present” (see FR-002).
§Errors
Returns SearchError::MissingApiKey when the selected backend requires a key
and none was supplied, or SearchError::Provider when cfg.endpoint is not a
valid URL or cfg.backend names an unknown backend.
Sourcepub async fn search(
&self,
client: &Client,
query: &str,
limit: usize,
) -> Result<Vec<SearchResult>, SearchError>
pub async fn search( &self, client: &Client, query: &str, limit: usize, ) -> Result<Vec<SearchResult>, SearchError>
§Errors
Returns SearchError on missing key, HTTP failure, timeout, or response parse
failure.
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
See SearchProvider::name.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SearchBackend
impl RefUnwindSafe for SearchBackend
impl Send for SearchBackend
impl Sync for SearchBackend
impl Unpin for SearchBackend
impl UnsafeUnpin for SearchBackend
impl UnwindSafe for SearchBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request