mirror of
https://github.com/NotAShelf/stash.git
synced 2026-04-12 22:17:41 +00:00
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a69648f81d0d094e11a3e0f0a19d3b8eccd5d
32 lines
809 B
Rust
32 lines
809 B
Rust
use crate::db::{ClipboardDb, SqliteClipboardDb};
|
|
|
|
use std::io::Read;
|
|
|
|
pub trait StoreCommand {
|
|
fn store(
|
|
&self,
|
|
input: impl Read,
|
|
max_dedupe_search: u64,
|
|
max_items: u64,
|
|
state: Option<String>,
|
|
) -> Result<(), crate::db::StashError>;
|
|
}
|
|
|
|
impl StoreCommand for SqliteClipboardDb {
|
|
fn store(
|
|
&self,
|
|
input: impl Read,
|
|
max_dedupe_search: u64,
|
|
max_items: u64,
|
|
state: Option<String>,
|
|
) -> Result<(), crate::db::StashError> {
|
|
if let Some("sensitive" | "clear") = state.as_deref() {
|
|
self.delete_last()?;
|
|
log::info!("Entry deleted");
|
|
} else {
|
|
self.store_entry(input, max_dedupe_search, max_items)?;
|
|
log::info!("Entry stored");
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|