Skip to content

Commit

Permalink
make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Oct 8, 2023
1 parent 827e8a5 commit a511d89
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 28 deletions.
8 changes: 4 additions & 4 deletions atuin-client/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ pub fn current_context() -> Context {

#[async_trait]
pub trait Database: Send + Sync + 'static {
async fn save(&mut self, h: &History) -> Result<()>;
async fn save_bulk(&mut self, h: &[History]) -> Result<()>;
async fn save(&self, h: &History) -> Result<()>;
async fn save_bulk(&self, h: &[History]) -> Result<()>;

async fn load(&self, id: &str) -> Result<Option<History>>;
async fn list(
Expand Down Expand Up @@ -192,7 +192,7 @@ impl Sqlite {

#[async_trait]
impl Database for Sqlite {
async fn save(&mut self, h: &History) -> Result<()> {
async fn save(&self, h: &History) -> Result<()> {
debug!("saving history to sqlite");
let mut tx = self.pool.begin().await?;
Self::save_raw(&mut tx, h).await?;
Expand All @@ -201,7 +201,7 @@ impl Database for Sqlite {
Ok(())
}

async fn save_bulk(&mut self, h: &[History]) -> Result<()> {
async fn save_bulk(&self, h: &[History]) -> Result<()> {
debug!("saving history to sqlite");

let mut tx = self.pool.begin().await?;
Expand Down
6 changes: 3 additions & 3 deletions atuin-client/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async fn sync_download(
key: &Key,
force: bool,
client: &api_client::Client<'_>,
db: &mut (impl Database + Send),
db: &(impl Database + Send),
) -> Result<(i64, i64)> {
debug!("starting sync download");

Expand Down Expand Up @@ -127,7 +127,7 @@ async fn sync_upload(
key: &Key,
_force: bool,
client: &api_client::Client<'_>,
db: &mut (impl Database + Send),
db: &(impl Database + Send),
) -> Result<()> {
debug!("starting sync upload");

Expand Down Expand Up @@ -188,7 +188,7 @@ async fn sync_upload(
Ok(())
}

pub async fn sync(settings: &Settings, force: bool, db: &mut (impl Database + Send)) -> Result<()> {
pub async fn sync(settings: &Settings, force: bool, db: &(impl Database + Send)) -> Result<()> {
let client = api_client::Client::new(
&settings.sync_address,
&settings.session_token,
Expand Down
10 changes: 5 additions & 5 deletions atuin/src/command/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ impl Cmd {
let db_path = PathBuf::from(settings.db_path.as_str());
let record_store_path = PathBuf::from(settings.record_store_path.as_str());

let mut db = Sqlite::new(db_path).await?;
let db = Sqlite::new(db_path).await?;
let mut store = SqliteStore::new(record_store_path).await?;

match self {
Self::History(history) => history.run(&settings, &mut db).await,
Self::Import(import) => import.run(&mut db).await,
Self::Stats(stats) => stats.run(&mut db, &settings).await,
Self::History(history) => history.run(&settings, &db).await,
Self::Import(import) => import.run(&db).await,
Self::Stats(stats) => stats.run(&db, &settings).await,
Self::Search(search) => search.run(db, &mut settings).await,

#[cfg(feature = "sync")]
Self::Sync(sync) => sync.run(settings, &mut db, &mut store).await,
Self::Sync(sync) => sync.run(settings, &db, &mut store).await,

#[cfg(feature = "sync")]
Self::Account(account) => account.run(settings).await,
Expand Down
8 changes: 4 additions & 4 deletions atuin/src/command/client/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ fn parse_fmt(format: &str) -> ParsedFmt {
impl Cmd {
#[allow(clippy::too_many_lines, clippy::cast_possible_truncation)]
async fn handle_start(
db: &mut impl Database,
db: &impl Database,
settings: &Settings,
command: &[String],
) -> Result<()> {
Expand Down Expand Up @@ -224,7 +224,7 @@ impl Cmd {
}

async fn handle_end(
db: &mut impl Database,
db: &impl Database,
settings: &Settings,
id: &str,
exit: i64,
Expand Down Expand Up @@ -267,7 +267,7 @@ impl Cmd {
}

async fn handle_list(
db: &mut impl Database,
db: &impl Database,
settings: &Settings,
context: atuin_client::database::Context,
session: bool,
Expand Down Expand Up @@ -309,7 +309,7 @@ impl Cmd {
Ok(())
}

pub async fn run(self, settings: &Settings, db: &mut impl Database) -> Result<()> {
pub async fn run(self, settings: &Settings, db: &impl Database) -> Result<()> {
let context = current_context();

match self {
Expand Down
8 changes: 4 additions & 4 deletions atuin/src/command/client/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub enum Cmd {
const BATCH_SIZE: usize = 100;

impl Cmd {
pub async fn run<DB: Database>(&self, db: &mut DB) -> Result<()> {
pub async fn run<DB: Database>(&self, db: &DB) -> Result<()> {
println!(" Atuin ");
println!("======================");
println!(" \u{1f30d} ");
Expand Down Expand Up @@ -104,11 +104,11 @@ impl Cmd {
pub struct HistoryImporter<'db, DB: Database> {
pb: ProgressBar,
buf: Vec<History>,
db: &'db mut DB,
db: &'db DB,
}

impl<'db, DB: Database> HistoryImporter<'db, DB> {
fn new(db: &'db mut DB, len: usize) -> Self {
fn new(db: &'db DB, len: usize) -> Self {
Self {
pb: ProgressBar::new(len as u64),
buf: Vec::with_capacity(BATCH_SIZE),
Expand Down Expand Up @@ -138,7 +138,7 @@ impl<'db, DB: Database> Loader for HistoryImporter<'db, DB> {
}
}

async fn import<I: Importer + Send, DB: Database>(db: &mut DB) -> Result<()> {
async fn import<I: Importer + Send, DB: Database>(db: &DB) -> Result<()> {
println!("Importing history from {}", I::NAME);

let mut importer = I::new().await?;
Expand Down
9 changes: 4 additions & 5 deletions atuin/src/command/client/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub struct Cmd {
}

impl Cmd {
pub async fn run(self, mut db: impl Database, settings: &mut Settings) -> Result<()> {
pub async fn run(self, db: impl Database, settings: &mut Settings) -> Result<()> {
if self.delete && self.query.is_empty() {
println!("Please specify a query to match the items you wish to delete. If you wish to delete all history, pass --delete-it-all");
return Ok(());
Expand Down Expand Up @@ -147,7 +147,7 @@ impl Cmd {
};

let mut entries =
run_non_interactive(settings, opt_filter.clone(), &self.query, &mut db).await?;
run_non_interactive(settings, opt_filter.clone(), &self.query, &db).await?;

if entries.is_empty() {
std::process::exit(1)
Expand All @@ -165,8 +165,7 @@ impl Cmd {
}

entries =
run_non_interactive(settings, opt_filter.clone(), &self.query, &mut db)
.await?;
run_non_interactive(settings, opt_filter.clone(), &self.query, &db).await?;
}
} else {
super::history::print_list(&entries, list_mode, self.format.as_deref());
Expand All @@ -183,7 +182,7 @@ async fn run_non_interactive(
settings: &Settings,
filter_options: OptFilters,
query: &[String],
db: &mut impl Database,
db: &impl Database,
) -> Result<Vec<History>> {
let dir = if filter_options.cwd.as_deref() == Some(".") {
Some(utils::get_current_dir())
Expand Down
2 changes: 1 addition & 1 deletion atuin/src/command/client/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn compute_stats(history: &[History], count: usize) -> Result<()> {
}

impl Cmd {
pub async fn run(&self, db: &mut impl Database, settings: &Settings) -> Result<()> {
pub async fn run(&self, db: &impl Database, settings: &Settings) -> Result<()> {
let context = current_context();
let words = if self.period.is_empty() {
String::from("all")
Expand Down
4 changes: 2 additions & 2 deletions atuin/src/command/client/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Cmd {
pub async fn run(
self,
settings: Settings,
db: &mut impl Database,
db: &impl Database,
store: &mut (impl Store + Send + Sync),
) -> Result<()> {
match self {
Expand Down Expand Up @@ -74,7 +74,7 @@ impl Cmd {
async fn run(
settings: &Settings,
force: bool,
db: &mut impl Database,
db: &impl Database,
store: &mut (impl Store + Send + Sync),
) -> Result<()> {
let (diff, remote_index) = sync::diff(settings, store).await?;
Expand Down

0 comments on commit a511d89

Please sign in to comment.