Making changes to store.

This commit is contained in:
2025-11-04 16:31:43 -06:00
parent 2420745dd1
commit 4876ac631a
4 changed files with 17 additions and 29 deletions

View File

@@ -23,7 +23,7 @@ mod store;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(version, about)] #[command(version, about)]
struct Args { struct Args {
/// Configuration file locaation. /// Configuration file location.
#[arg(short, long, value_name = "FILE")] #[arg(short, long, value_name = "FILE")]
config: Option<PathBuf>, config: Option<PathBuf>,
@@ -42,6 +42,10 @@ struct Args {
/// Set the number of requests handled per minute. /// Set the number of requests handled per minute.
#[arg(short, long, default_value_t = 30)] #[arg(short, long, default_value_t = 30)]
requests_per_min: u64, requests_per_min: u64,
/// Path to paste store
#[arg(short, long)]
store_path: PathBuf,
} }
async fn default_handler() -> Response { async fn default_handler() -> Response {

12
src/store.rs Normal file
View 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() }
}
}

View File

@@ -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!())
}
}

View File

@@ -1 +0,0 @@
pub(crate) mod keyval;