From 4876ac631a6ab11da67f90f6c32816c84151c1c2 Mon Sep 17 00:00:00 2001 From: Micheal Smith Date: Tue, 4 Nov 2025 16:31:43 -0600 Subject: [PATCH] Making changes to store. --- src/main.rs | 6 +++++- src/store.rs | 12 ++++++++++++ src/store/keyval/mod.rs | 27 --------------------------- src/store/mod.rs | 1 - 4 files changed, 17 insertions(+), 29 deletions(-) create mode 100644 src/store.rs delete mode 100644 src/store/keyval/mod.rs delete mode 100644 src/store/mod.rs diff --git a/src/main.rs b/src/main.rs index 33614c2..611c0dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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, @@ -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 { diff --git a/src/store.rs b/src/store.rs new file mode 100644 index 0000000..576669f --- /dev/null +++ b/src/store.rs @@ -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) -> Store { + Store { path: path.as_ref().to_path_buf() } + } +} diff --git a/src/store/keyval/mod.rs b/src/store/keyval/mod.rs deleted file mode 100644 index febc1ce..0000000 --- a/src/store/keyval/mod.rs +++ /dev/null @@ -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) -> Result<()> { - Ok(()) -} - -pub struct KeyVal { - db_path: PathBuf, -} - -impl KeyVal { - pub fn new(database_path: impl AsRef) -> Result { - 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 { - Ok(nanoid!()) - } -} diff --git a/src/store/mod.rs b/src/store/mod.rs deleted file mode 100644 index a0c3c06..0000000 --- a/src/store/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub(crate) mod keyval;