aboutsummaryrefslogtreecommitdiff
path: root/src/modules/search.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/search.rs')
-rw-r--r--src/modules/search.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/modules/search.rs b/src/modules/search.rs
index 14a0f9e..12a2c80 100644
--- a/src/modules/search.rs
+++ b/src/modules/search.rs
@@ -16,18 +16,20 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use std::{fmt::Write, sync::Mutex};
+use std::{
+ fmt::Write,
+ sync::{LazyLock, Mutex},
+};
-use once_cell::sync::Lazy;
use tantivy::schema;
use tempfile::TempDir;
const SEARCH_INDEX_SIZE: usize = 10_000_000;
const SEARCH_SIZE: usize = 10;
-static INDEX_PATH: Lazy<Mutex<TempDir>> =
- Lazy::new(|| Mutex::new(TempDir::new().unwrap()));
-static SCHEMA: Lazy<Mutex<schema::Schema>> = Lazy::new(|| {
+static INDEX_PATH: LazyLock<Mutex<TempDir>> =
+ LazyLock::new(|| Mutex::new(TempDir::new().unwrap()));
+static SCHEMA: LazyLock<Mutex<schema::Schema>> = LazyLock::new(|| {
Mutex::new({
let mut schema_builder = schema::Schema::builder();
@@ -38,7 +40,7 @@ static SCHEMA: Lazy<Mutex<schema::Schema>> = Lazy::new(|| {
schema_builder.build()
})
});
-static INDEX: Lazy<Mutex<tantivy::Index>> = Lazy::new(|| {
+static INDEX: LazyLock<Mutex<tantivy::Index>> = LazyLock::new(|| {
Mutex::new({
tantivy::Index::create_in_dir(
&(*INDEX_PATH.lock().unwrap()),
@@ -47,9 +49,10 @@ static INDEX: Lazy<Mutex<tantivy::Index>> = Lazy::new(|| {
.unwrap()
})
});
-static INDEX_WRITER: Lazy<Mutex<tantivy::IndexWriter>> = Lazy::new(|| {
- Mutex::new((*INDEX.lock().unwrap()).writer(SEARCH_INDEX_SIZE).unwrap())
-});
+static INDEX_WRITER: LazyLock<Mutex<tantivy::IndexWriter>> =
+ LazyLock::new(|| {
+ Mutex::new((*INDEX.lock().unwrap()).writer(SEARCH_INDEX_SIZE).unwrap())
+ });
pub(super) fn module(router: &mut windmark::Router) {
crate::route::track_mount(