Making changes to store.
This commit is contained in:
@@ -23,7 +23,7 @@ mod store;
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about)]
|
||||
struct Args {
|
||||
/// Configuration file locaation.
|
||||
/// Configuration file location.
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
config: Option<PathBuf>,
|
||||
|
||||
@@ -42,6 +42,10 @@ struct Args {
|
||||
/// Set the number of requests handled per minute.
|
||||
#[arg(short, long, default_value_t = 30)]
|
||||
requests_per_min: u64,
|
||||
|
||||
/// Path to paste store
|
||||
#[arg(short, long)]
|
||||
store_path: PathBuf,
|
||||
}
|
||||
|
||||
async fn default_handler() -> Response {
|
||||
|
||||
12
src/store.rs
Normal file
12
src/store.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use rocksdb::DB;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub struct Store {
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
impl Store {
|
||||
pub async fn new(path: impl AsRef<Path>) -> Store {
|
||||
Store { path: path.as_ref().to_path_buf() }
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// Default rocksdb storage.
|
||||
|
||||
use bytes::Bytes;
|
||||
use color_eyre::eyre::Result;
|
||||
use nanoid::nanoid;
|
||||
use rocksdb::{DB, Options};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn init(_path: impl AsRef<str>) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub struct KeyVal {
|
||||
db_path: PathBuf,
|
||||
}
|
||||
|
||||
impl KeyVal {
|
||||
pub fn new(database_path: impl AsRef<Path>) -> Result<KeyVal> {
|
||||
Ok(KeyVal { db_path: database_path.as_ref().into() })
|
||||
}
|
||||
|
||||
// Store value into the database, and return the key that was assigned to it.
|
||||
pub async fn store(&self, data: impl AsRef<[u8]>) -> Result<String> {
|
||||
Ok(nanoid!())
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
pub(crate) mod keyval;
|
||||
Reference in New Issue
Block a user