@@ 133,6 133,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
+name = "camino"
+version = "1.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "07fd178c5af4d59e83498ef15cf3f154e1a6f9d091270cb86283c65ef44e9ef0"
+
+[[package]]
name = "cc"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ 1089,6 1095,7 @@ name = "sota-slack-spotter"
version = "0.1.0"
dependencies = [
"anyhow",
+ "camino",
"env_logger",
"itertools",
"lazy_static",
@@ 4,6 4,7 @@ name = "sota-slack-spotter"
version = "0.1.0"
[dependencies]
anyhow = "1.0"
+camino = "1.0"
env_logger = "0.9"
itertools = "0.10"
lazy_static = "1.4.0"
@@ 3,11 3,11 @@ use std::{
fs::File,
hash::Hash,
marker::PhantomData,
- path::PathBuf,
time::{Duration, SystemTime},
};
use anyhow::Result;
+use camino::Utf8PathBuf;
use log::debug;
use serde::{de::DeserializeOwned, Serialize};
@@ 19,7 19,7 @@ use crate::{callsign::Callsigns, sota::SOTAItem};
/// - Spots and alerts that have been dispatched
/// - Callsigns, which are unlikely to change on every run
pub struct Cache<T> {
- path: PathBuf,
+ path: Utf8PathBuf,
phantom: PhantomData<T>,
}
@@ 28,7 28,7 @@ where
T: Hash + Eq + Serialize + DeserializeOwned,
{
/// Instantiates a new Cache, but doesn't load anything from it.
- pub fn new<P: Into<PathBuf>>(path: P) -> Self {
+ pub fn new<P: Into<Utf8PathBuf>>(path: P) -> Self {
Self {
path: path.into(),
phantom: PhantomData,
@@ 68,8 68,7 @@ where
Err(e) => {
debug!(
"Failed to load {} (continuing with empty set): {}",
- &self.path.to_string_lossy(),
- e
+ &self.path, e
);
HashSet::new()
}
@@ 93,7 92,7 @@ impl<T: SOTAItem> Cache<T> {
pub fn reconcile<I: IntoIterator<Item = T>>(&self, new: I) -> Result<()> {
let mut data = self.load_or_empty();
- let path = &self.path.to_string_lossy();
+ let path = &self.path;
let before = data.len();
clean(&mut data);
let after = data.len();