Connect store to indexes
This commit is contained in:
parent
f2c17d2e66
commit
8fd2d4ebf3
3 changed files with 64 additions and 36 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use std::marker::PhantomData;
|
||||
use std::path::Path;
|
||||
use tokio::fs::{DirBuilder, File, OpenOptions};
|
||||
use std::path::PathBuf;
|
||||
use tokio::fs::{File, OpenOptions};
|
||||
use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt, SeekFrom};
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
|
@ -38,7 +38,7 @@ where
|
|||
K: Encode + Decode + Ord,
|
||||
V: Encode + Decode + Clone + Eq + Hash,
|
||||
{
|
||||
pub async fn new(file_name: &str) -> Result<Index<K, V>> {
|
||||
pub async fn new(file_name: PathBuf) -> Result<Index<K, V>> {
|
||||
let file: File = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
|
|
@ -56,7 +56,7 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn connect(file_name: &str) -> Result<Index<K, V>> {
|
||||
pub async fn connect(file_name: PathBuf) -> Result<Index<K, V>> {
|
||||
let mut file: File = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
|
|
@ -124,7 +124,7 @@ mod tests {
|
|||
index.insert("bar".to_string(), 125).await.unwrap();
|
||||
index.insert("bar".to_string(), 126).await.unwrap();
|
||||
|
||||
let lookup = index.lookup("foo".to_string()).await.unwrap().unwrap();
|
||||
let lookup = index.lookup(&"foo".to_string()).await.unwrap().unwrap();
|
||||
assert_eq!(lookup.len(), 2);
|
||||
assert!(lookup.contains(&123));
|
||||
assert!(lookup.contains(&124));
|
||||
|
|
@ -139,7 +139,7 @@ mod tests {
|
|||
value_type: PhantomData::<u32>,
|
||||
};
|
||||
|
||||
let lookup = decoded.lookup("foo".to_string()).await.unwrap().unwrap();
|
||||
let lookup = decoded.lookup(&"foo".to_string()).await.unwrap().unwrap();
|
||||
assert_eq!(lookup.len(), 2);
|
||||
assert!(lookup.contains(&123));
|
||||
assert!(lookup.contains(&124));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue