aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-08-27 22:29:06 -0700
committerFuwn <[email protected]>2022-08-27 22:29:06 -0700
commit83fc1aab2e15f60b6e7b85e7831d6591b4d1ab36 (patch)
tree43ddb3f37117e61b1caa619b72c96eafa21cf63b /src/modules
parentfix(main.rs): enable feature for actions (diff)
downloadlocus-83fc1aab2e15f60b6e7b85e7831d6591b4d1ab36.tar.xz
locus-83fc1aab2e15f60b6e7b85e7831d6591b4d1ab36.zip
feat: bump toolchain to nightly-2022-08-23
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/contact.rs6
-rw-r--r--src/modules/interests.rs6
-rw-r--r--src/modules/random.rs2
-rw-r--r--src/modules/remarks.rs5
-rw-r--r--src/modules/search.rs22
-rw-r--r--src/modules/skills.rs6
-rw-r--r--src/modules/stocks.rs5
-rw-r--r--src/modules/uptime.rs5
8 files changed, 30 insertions, 27 deletions
diff --git a/src/modules/contact.rs b/src/modules/contact.rs
index 9999aa9..c9ce993 100644
--- a/src/modules/contact.rs
+++ b/src/modules/contact.rs
@@ -16,11 +16,13 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use std::{collections::HashMap, lazy::SyncLazy};
+use std::collections::HashMap;
+
+use once_cell::sync::Lazy;
type ContactMap = HashMap<String, HashMap<String, String>>;
-static CONTACT_MAP: SyncLazy<ContactMap> = SyncLazy::new(|| {
+static CONTACT_MAP: Lazy<ContactMap> = Lazy::new(|| {
serde_json::from_str(include_str!("../../content/json/contacts.json"))
.unwrap()
});
diff --git a/src/modules/interests.rs b/src/modules/interests.rs
index 2cd8328..4db805f 100644
--- a/src/modules/interests.rs
+++ b/src/modules/interests.rs
@@ -16,11 +16,13 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use std::{collections::HashMap, lazy::SyncLazy};
+use std::collections::HashMap;
+
+use once_cell::sync::Lazy;
type InterestMap = HashMap<String, HashMap<String, String>>;
-static INTEREST_MAP: SyncLazy<InterestMap> = SyncLazy::new(|| {
+static INTEREST_MAP: Lazy<InterestMap> = Lazy::new(|| {
serde_json::from_str(include_str!("../../content/json/interests.json"))
.unwrap()
});
diff --git a/src/modules/random.rs b/src/modules/random.rs
index 799376a..9320ac6 100644
--- a/src/modules/random.rs
+++ b/src/modules/random.rs
@@ -16,7 +16,7 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use rand::seq::SliceRandom;
+use rand::prelude::SliceRandom;
pub fn module(router: &mut windmark::Router) {
crate::route::track_mount(
diff --git a/src/modules/remarks.rs b/src/modules/remarks.rs
index 780b72a..8cd9d6c 100644
--- a/src/modules/remarks.rs
+++ b/src/modules/remarks.rs
@@ -16,11 +16,10 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use std::lazy::SyncLazy;
-
+use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
-static REMARKS: SyncLazy<Vec<Remark>> = SyncLazy::new(|| {
+static REMARKS: Lazy<Vec<Remark>> = Lazy::new(|| {
serde_json::from_str(include_str!("../../content/json/remarks.json")).unwrap()
});
diff --git a/src/modules/search.rs b/src/modules/search.rs
index 2179215..6ad3898 100644
--- a/src/modules/search.rs
+++ b/src/modules/search.rs
@@ -16,17 +16,18 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use std::{fmt::Write, lazy::SyncLazy, sync::Mutex};
+use std::{fmt::Write, sync::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: SyncLazy<Mutex<TempDir>> =
- SyncLazy::new(|| Mutex::new(TempDir::new().unwrap()));
-static SCHEMA: SyncLazy<Mutex<schema::Schema>> = SyncLazy::new(|| {
+static INDEX_PATH: Lazy<Mutex<TempDir>> =
+ Lazy::new(|| Mutex::new(TempDir::new().unwrap()));
+static SCHEMA: Lazy<Mutex<schema::Schema>> = Lazy::new(|| {
Mutex::new({
let mut schema_builder = schema::Schema::builder();
@@ -37,7 +38,7 @@ static SCHEMA: SyncLazy<Mutex<schema::Schema>> = SyncLazy::new(|| {
schema_builder.build()
})
});
-static INDEX: SyncLazy<Mutex<tantivy::Index>> = SyncLazy::new(|| {
+static INDEX: Lazy<Mutex<tantivy::Index>> = Lazy::new(|| {
Mutex::new({
tantivy::Index::create_in_dir(
&(*INDEX_PATH.lock().unwrap()),
@@ -46,10 +47,9 @@ static INDEX: SyncLazy<Mutex<tantivy::Index>> = SyncLazy::new(|| {
.unwrap()
})
});
-static INDEX_WRITER: SyncLazy<Mutex<tantivy::IndexWriter>> =
- SyncLazy::new(|| {
- Mutex::new((*INDEX.lock().unwrap()).writer(SEARCH_INDEX_SIZE).unwrap())
- });
+static INDEX_WRITER: Lazy<Mutex<tantivy::IndexWriter>> = Lazy::new(|| {
+ Mutex::new((*INDEX.lock().unwrap()).writer(SEARCH_INDEX_SIZE).unwrap())
+});
pub(super) fn module(router: &mut windmark::Router) {
crate::route::track_mount(
@@ -85,10 +85,10 @@ pub(super) fn module(router: &mut windmark::Router) {
let top_docs = searcher
.search(
&tantivy::query::QueryParser::for_index(
- &(*INDEX.lock().unwrap()),
+ &INDEX.lock().unwrap(),
vec![path, description, content],
)
- .parse_query(&query.0.to_string())
+ .parse_query(&query.0)
.unwrap(),
&tantivy::collector::TopDocs::with_limit(SEARCH_SIZE),
)
diff --git a/src/modules/skills.rs b/src/modules/skills.rs
index bd05ceb..ec2337d 100644
--- a/src/modules/skills.rs
+++ b/src/modules/skills.rs
@@ -16,11 +16,13 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use std::{collections::HashMap, lazy::SyncLazy};
+use std::collections::HashMap;
+
+use once_cell::sync::Lazy;
type SkillTree = HashMap<String, Vec<HashMap<String, Option<Vec<String>>>>>;
-static SKILL_TREE: SyncLazy<SkillTree> = SyncLazy::new(|| {
+static SKILL_TREE: Lazy<SkillTree> = Lazy::new(|| {
serde_json::from_str(include_str!("../../content/json/skills.json")).unwrap()
});
diff --git a/src/modules/stocks.rs b/src/modules/stocks.rs
index e066dce..0d6950c 100644
--- a/src/modules/stocks.rs
+++ b/src/modules/stocks.rs
@@ -16,13 +16,12 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use std::lazy::SyncLazy;
-
+use once_cell::sync::Lazy;
use serde::Deserialize;
use crate::{route::track_mount, success};
-static REFERRALS: SyncLazy<Vec<Referral>> = SyncLazy::new(|| {
+static REFERRALS: Lazy<Vec<Referral>> = Lazy::new(|| {
serde_json::from_str(include_str!("../../content/json/stock_referrals.json"))
.unwrap()
});
diff --git a/src/modules/uptime.rs b/src/modules/uptime.rs
index c0b09cb..774fb37 100644
--- a/src/modules/uptime.rs
+++ b/src/modules/uptime.rs
@@ -16,11 +16,10 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use std::lazy::SyncLazy;
-
+use once_cell::sync::Lazy;
use tokio::time::Instant;
-static UPTIME: SyncLazy<Instant> = SyncLazy::new(Instant::now);
+static UPTIME: Lazy<Instant> = Lazy::new(Instant::now);
pub fn module(router: &mut windmark::Router) {
UPTIME.elapsed();