about summary refs log tree commit diff
path: root/src/search/mod.rs
diff options
context:
space:
mode:
authorAlexander_Kabui <alexanderkabui@proton.me>2026-11-17 12:11:19 +0300
committerAlexander_Kabui <alexanderkabui@proton.me>2026-11-17 14:06:50 +0300
commitf76043bf82b6c86b5e844b27b53e957d770aeb33 (patch)
tree5b4257c2523410f077e9fbc4f71f3fd797360b9f /src/search/mod.rs
parente13bbd27d0b7addd277d0f50d9e90fee2a936211 (diff)
downloadgenenetwork4-search/extract-engine.tar.gz
* src/search (engine): no default arm, so a wrong name is refused. search/extract-engine
An unrecognised SEARCH_ENGINE used to fall through to the gn3 proxy, which
turned a typo into a silently different engine. The arms are now explicit -
"crate"/"native" for the in-process engine, "forward" for the proxy - and
anything else returns the value it was given. src/search/native.rs is deleted;
the former name resolves through the same arm.
Diffstat (limited to 'src/search/mod.rs')
-rw-r--r--src/search/mod.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/search/mod.rs b/src/search/mod.rs
index f8797e7..3e2611e 100644
--- a/src/search/mod.rs
+++ b/src/search/mod.rs
@@ -86,14 +86,13 @@
 //! impl is speculation). The overnight schedule overrides that: the
 //! [`Engine`] trait is defined so the native engine can land behind
 //! it. The gn3-forwarding implementation ([`gn3::Gn3`]) remains the
-//! default backend; [`native::Native`] is opt-in via `SEARCH_ENGINE`
+//! default backend; the in-process engine is opt-in via `SEARCH_ENGINE`
 //! (see [`search`]).
 
 use std::future::Future;
 
 pub mod gn3;
 pub mod gnindex;
-pub mod native;
 
 /// Run a search through the configured engine: the gn3 forwarder by
 /// default, the native xapian engine when `SEARCH_ENGINE=native`
@@ -106,9 +105,20 @@ pub async fn search(
     page: u64,
 ) -> Result<Vec<SearchHit>, SearchError> {
     match crate::config::Config::load().search_engine.as_str() {
-        "native" => native::Native.search(q, type_, limit, page).await,
-          "crate" => gnindex::CrateEngine::from_config().search(q, type_, limit, page).await,
-        _ => gn3::Gn3.search(q, type_, limit, page).await,
+        // The in-process engine, in the crate; `native` is its former name.
+        "crate" | "native" => {
+            gnindex::CrateEngine::from_config()
+                .search(q, type_, limit, page)
+                .await
+        }
+        // The gn3 proxy, asked over HTTP. Deleted together with gn3.
+        "forward" => gn3::Gn3.search(q, type_, limit, page).await,
+        // No default arm: an unrecognised value is a misconfiguration, and a
+        // silent fall-through would hide it behind whichever engine happened to
+        // be last in the match.
+        other => Err(SearchError::Internal(format!(
+            "SEARCH_ENGINE={other:?} is not an engine: expected \"crate\", \"native\" or \"forward\""
+        ))),
     }
 }