mirror of
https://github.com/NotAShelf/stash.git
synced 2026-04-21 17:53:39 +00:00
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I9092f93c29fcbe99c90483875f4acd0c6a6a6964
48 lines
1.1 KiB
Rust
48 lines
1.1 KiB
Rust
use std::io::Read;
|
|
|
|
use crate::db::{ClipboardDb, SqliteClipboardDb};
|
|
|
|
#[allow(clippy::too_many_arguments)]
|
|
pub trait StoreCommand {
|
|
fn store(
|
|
&self,
|
|
input: impl Read,
|
|
max_dedupe_search: u64,
|
|
max_items: u64,
|
|
state: Option<String>,
|
|
excluded_apps: &[String],
|
|
min_size: Option<usize>,
|
|
max_size: usize,
|
|
) -> Result<(), crate::db::StashError>;
|
|
}
|
|
|
|
impl StoreCommand for SqliteClipboardDb {
|
|
fn store(
|
|
&self,
|
|
input: impl Read,
|
|
max_dedupe_search: u64,
|
|
max_items: u64,
|
|
state: Option<String>,
|
|
excluded_apps: &[String],
|
|
min_size: Option<usize>,
|
|
max_size: usize,
|
|
) -> 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,
|
|
Some(excluded_apps),
|
|
min_size,
|
|
max_size,
|
|
None, // no pre-computed hash for CLI store
|
|
None, // no mime types for CLI store
|
|
)?;
|
|
log::info!("entry stored");
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|