mirror of
https://github.com/NotAShelf/stash.git
synced 2026-04-18 00:28:12 +00:00
db: switch to sqlite as the primary backend
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a69648f81d0d094e11a3e0f0a19d3b8eccd5d
This commit is contained in:
parent
efcbe17d73
commit
4f725425fc
12 changed files with 246 additions and 274 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use crate::db::{ClipboardDb, SledClipboardDb};
|
||||
use crate::db::{ClipboardDb, SqliteClipboardDb};
|
||||
|
||||
use std::io::{Read, Write};
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ pub trait DecodeCommand {
|
|||
) -> Result<(), StashError>;
|
||||
}
|
||||
|
||||
impl DecodeCommand for SledClipboardDb {
|
||||
impl DecodeCommand for SqliteClipboardDb {
|
||||
fn decode(
|
||||
&self,
|
||||
in_: impl Read,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::db::{ClipboardDb, SledClipboardDb, StashError};
|
||||
use crate::db::{ClipboardDb, SqliteClipboardDb, StashError};
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ pub trait DeleteCommand {
|
|||
fn delete(&self, input: impl Read) -> Result<usize, StashError>;
|
||||
}
|
||||
|
||||
impl DeleteCommand for SledClipboardDb {
|
||||
impl DeleteCommand for SqliteClipboardDb {
|
||||
fn delete(&self, input: impl Read) -> Result<usize, StashError> {
|
||||
match self.delete_entries(input) {
|
||||
Ok(deleted) => {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use crate::db::{ClipboardDb, SledClipboardDb};
|
||||
use crate::db::{ClipboardDb, SqliteClipboardDb};
|
||||
use std::io::Write;
|
||||
|
||||
pub trait ListCommand {
|
||||
fn list(&self, out: impl Write, preview_width: u32) -> Result<(), crate::db::StashError>;
|
||||
}
|
||||
|
||||
impl ListCommand for SledClipboardDb {
|
||||
impl ListCommand for SqliteClipboardDb {
|
||||
fn list(&self, out: impl Write, preview_width: u32) -> Result<(), crate::db::StashError> {
|
||||
self.list_entries(out, preview_width)?;
|
||||
log::info!("Listed clipboard entries");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::db::{ClipboardDb, SledClipboardDb};
|
||||
use crate::db::{ClipboardDb, SqliteClipboardDb};
|
||||
|
||||
use crate::db::StashError;
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ pub trait QueryCommand {
|
|||
fn query_delete(&self, query: &str) -> Result<usize, StashError>;
|
||||
}
|
||||
|
||||
impl QueryCommand for SledClipboardDb {
|
||||
impl QueryCommand for SqliteClipboardDb {
|
||||
fn query_delete(&self, query: &str) -> Result<usize, StashError> {
|
||||
<SledClipboardDb as ClipboardDb>::delete_query(self, query)
|
||||
<SqliteClipboardDb as ClipboardDb>::delete_query(self, query)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::db::{ClipboardDb, SledClipboardDb};
|
||||
use crate::db::{ClipboardDb, SqliteClipboardDb};
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ pub trait StoreCommand {
|
|||
) -> Result<(), crate::db::StashError>;
|
||||
}
|
||||
|
||||
impl StoreCommand for SledClipboardDb {
|
||||
impl StoreCommand for SqliteClipboardDb {
|
||||
fn store(
|
||||
&self,
|
||||
input: impl Read,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::db::{ClipboardDb, SledClipboardDb};
|
||||
use crate::db::{ClipboardDb, SqliteClipboardDb};
|
||||
|
||||
use crate::db::StashError;
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ pub trait WipeCommand {
|
|||
fn wipe(&self) -> Result<(), StashError>;
|
||||
}
|
||||
|
||||
impl WipeCommand for SledClipboardDb {
|
||||
impl WipeCommand for SqliteClipboardDb {
|
||||
fn wipe(&self) -> Result<(), StashError> {
|
||||
self.wipe_db()?;
|
||||
log::info!("Database wiped");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue