about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander_Kabui <alexanderkabua@gmail.com>2026-10-07 10:29:24 +0300
committerAlexander_Kabui <alexanderkabua@gmail.com>2026-10-07 10:29:24 +0300
commitb68531c40d91cadfd868e4b65ff92989ffd4fb27 (patch)
tree1a19ec19d674b6b7a38e5d46be238341bb92310f /src
parent80c52c495abc58d07df42ed825d7c40b1df2e767 (diff)
downloadgenenetwork4-b68531c40d91cadfd868e4b65ff92989ffd4fb27.tar.gz
src/search/native.rs, src/search/mod.rs, tests/search_native*.rs: apply
rustfmt to the native engine code (lane round-1 files were not
rustfmt-clean; pre-existing drift in config.rs, routes/search.rs,
tests/search_engine.rs is untouched — the parked house question).
Diffstat (limited to 'src')
-rw-r--r--src/search/native.rs33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/search/native.rs b/src/search/native.rs
index 665477a..5e5e254 100644
--- a/src/search/native.rs
+++ b/src/search/native.rs
@@ -44,8 +44,9 @@
 
 use super::{Engine, SearchError, SearchHit};
 use std::sync::{Mutex, OnceLock};
-use xapian_rs::{Database, Enquire, FieldProcessor, Operator, Query, QueryParser, Stem,
-    StemStrategy};
+use xapian_rs::{
+    Database, Enquire, FieldProcessor, Operator, Query, QueryParser, Stem, StemStrategy,
+};
 
 /// MSet bound for full-match-set retrieval: deliberately large so the
 /// whole match set comes back regardless of the forwarded `limit`
@@ -112,7 +113,11 @@ struct LowercaseGroupProcessor;
 
 impl FieldProcessor for LowercaseGroupProcessor {
     fn process(&self, term: &str) -> Option<Query> {
-        Some(Query::term(format!("XG{}", term.to_lowercase()), None, None))
+        Some(Query::term(
+            format!("XG{}", term.to_lowercase()),
+            None,
+            None,
+        ))
     }
 }
 
@@ -135,9 +140,7 @@ impl Engine for Native {
         let search_type = type_.to_string();
         tokio::task::spawn_blocking(move || search_blocking(&query, &search_type, limit))
             .await
-            .map_err(|e| {
-                SearchError::Internal(format!("native search task failed to join: {e}"))
-            })?
+            .map_err(|e| SearchError::Internal(format!("native search task failed to join: {e}")))?
     }
 }
 
@@ -223,9 +226,8 @@ fn open_database(path: &str) -> Result<Database, SearchError> {
 /// not hold what gn3 would serve — `Misbehaving`, the doc-data analogue
 /// of an undecodable backend response body.
 fn hit_from_doc_data(data: &[u8]) -> Result<SearchHit, SearchError> {
-    serde_json::from_slice::<SearchHit>(data).map_err(|e| {
-        SearchError::Misbehaving(format!("xapian doc data is not a search hit: {e}"))
-    })
+    serde_json::from_slice::<SearchHit>(data)
+        .map_err(|e| SearchError::Misbehaving(format!("xapian doc data is not a search hit: {e}")))
 }
 
 #[cfg(test)]
@@ -296,7 +298,10 @@ mod tests {
             b6.contains("XGb6"),
             "group:B6 must lowercase to XGb6, got {b6:?}"
         );
-        assert!(!b6.contains("XGB6"), "group must not emit the raw-case term");
+        assert!(
+            !b6.contains("XGB6"),
+            "group must not emit the raw-case term"
+        );
     }
 
     /// The probabilistic-prefix registrations (C3.3): description, rif,
@@ -329,16 +334,14 @@ mod tests {
     /// The index-open guards, without touching a real index.
     #[test]
     fn open_database_maps_failures_onto_the_seam_vocabulary() {
-        assert!(matches!(
-            open_database(""),
-            Err(SearchError::Internal(_))
-        ));
+        assert!(matches!(open_database(""), Err(SearchError::Internal(_))));
         assert!(matches!(
             open_database("/nonexistent/gn4-native-test-index"),
             Err(SearchError::Unreachable(_))
         ));
         // A real directory that is not an index.
-        let not_an_index = std::env::temp_dir().join(format!("gn4-not-an-index-{}", std::process::id()));
+        let not_an_index =
+            std::env::temp_dir().join(format!("gn4-not-an-index-{}", std::process::id()));
         std::fs::create_dir_all(&not_an_index).unwrap();
         assert!(matches!(
             open_database(not_an_index.to_str().unwrap()),