diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index f129876a1..9f1c49c05 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -27,7 +27,7 @@ jobs: uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 # Ensure that the latest version of Cargo is installed - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1 + uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203 # v1 with: toolchain: stable - uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2 @@ -43,7 +43,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - - uses: EmbarkStudios/cargo-deny-action@8371184bd11e21dcf8ac82ebf8c9c9f74ebf7268 # v2 + - uses: EmbarkStudios/cargo-deny-action@34899fc7ba81ca6268d5947a7a16b4649013fea1 # v2 with: command: check bans licenses sources diff --git a/Cargo.toml b/Cargo.toml index 35894eb6c..68e6126b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,15 +4,15 @@ version = "0.9.5" authors = ["the rustic-rs team"] categories = ["command-line-utilities"] documentation = "https://docs.rs/rustic-rs" -edition = "2021" +edition = "2024" homepage = "https://rustic.cli.rs/" include = ["src/**/*", "LICENSE-*", "README.md", "config/**/*"] keywords = ["backup", "restic", "deduplication", "encryption", "cli"] license = "Apache-2.0 OR MIT" readme = "README.md" repository = "https://github.com/rustic-rs/rustic" -resolver = "2" -rust-version = "1.80.0" +resolver = "3" +rust-version = "1.85.0" description = """ rustic - fast, encrypted, deduplicated backups powered by Rust """ diff --git a/src/application.rs b/src/application.rs index cd6160747..def588da2 100644 --- a/src/application.rs +++ b/src/application.rs @@ -2,10 +2,10 @@ use std::{env, process}; use abscissa_core::{ - application::{self, fatal_error, AppCell}, + Application, Component, FrameworkError, FrameworkErrorKind, Shutdown, StandardPaths, + application::{self, AppCell, fatal_error}, config::{self, CfgCell}, terminal::component::Terminal, - Application, Component, FrameworkError, FrameworkErrorKind, Shutdown, StandardPaths, }; use anyhow::Result; @@ -100,7 +100,9 @@ impl Application for RusticApp { // set all given environment variables for (env, value) in &config.global.env { - env::set_var(env, value); + unsafe { + env::set_var(env, value); + } } let global_hooks = config.global.hooks.clone(); diff --git a/src/commands.rs b/src/commands.rs index 89e29fa7b..16525b2de 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -42,6 +42,7 @@ use crate::commands::mount::MountCmd; #[cfg(feature = "webdav")] use crate::commands::webdav::WebDavCmd; use crate::{ + Application, RUSTIC_APP, commands::{ backup::BackupCmd, cat::CatCmd, check::CheckCmd, completions::CompletionsCmd, config::ConfigCmd, copy::CopyCmd, diff::DiffCmd, docs::DocsCmd, dump::DumpCmd, @@ -51,21 +52,20 @@ use crate::{ tag::TagCmd, }, config::RusticConfig, - Application, RUSTIC_APP, }; use abscissa_core::{ - config::Override, terminal::ColorChoice, Command, Configurable, FrameworkError, - FrameworkErrorKind, Runnable, Shutdown, + Command, Configurable, FrameworkError, FrameworkErrorKind, Runnable, Shutdown, + config::Override, terminal::ColorChoice, }; use anyhow::Result; use clap::builder::{ - styling::{AnsiColor, Effects}, Styles, + styling::{AnsiColor, Effects}, }; use convert_case::{Case, Casing}; use human_panic::setup_panic; -use log::{info, log, Level}; +use log::{Level, info, log}; use simplelog::{CombinedLogger, LevelFilter, TermLogger, TerminalMode, WriteLogger}; use self::find::FindCmd; diff --git a/src/commands/backup.rs b/src/commands/backup.rs index db620b3d9..fcf92124f 100644 --- a/src/commands/backup.rs +++ b/src/commands/backup.rs @@ -4,15 +4,16 @@ use std::path::PathBuf; use std::{collections::BTreeMap, env}; use crate::{ + Application, RUSTIC_APP, commands::{init::init, snapshots::fill_table}, config::{hooks::Hooks, parse_labels}, helpers::{bold_cell, bytes_size_to_string, table}, repository::CliRepo, - status_err, Application, RUSTIC_APP, + status_err, }; use abscissa_core::{Command, Runnable, Shutdown}; -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{Context, Result, anyhow, bail}; use clap::ValueHint; use comfy_table::Cell; use conflate::Merge; @@ -21,9 +22,9 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; use rustic_core::{ - repofile::SnapshotFile, BackupOptions, CommandInput, ConfigOptions, IndexedIds, KeyOptions, - LocalSourceFilterOptions, LocalSourceSaveOptions, ParentOptions, PathList, ProgressBars, - Repository, SnapshotOptions, + BackupOptions, CommandInput, ConfigOptions, IndexedIds, KeyOptions, LocalSourceFilterOptions, + LocalSourceSaveOptions, ParentOptions, PathList, ProgressBars, Repository, SnapshotOptions, + repofile::SnapshotFile, }; /// `backup` subcommand @@ -358,7 +359,9 @@ impl BackupCmd { } #[cfg(not(feature = "prometheus"))] { - warn!("not pushing prometheus metrics - this rustic version is compiled without prometheus support"); + warn!( + "not pushing prometheus metrics - this rustic version is compiled without prometheus support" + ); } } diff --git a/src/commands/cat.rs b/src/commands/cat.rs index dde621118..23ccac664 100644 --- a/src/commands/cat.rs +++ b/src/commands/cat.rs @@ -1,6 +1,6 @@ //! `cat` subcommand -use crate::{status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; diff --git a/src/commands/check.rs b/src/commands/check.rs index b25628bb0..43e1ccf49 100644 --- a/src/commands/check.rs +++ b/src/commands/check.rs @@ -1,6 +1,6 @@ //! `check` subcommand -use crate::{repository::CliOpenRepo, status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, repository::CliOpenRepo, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; use anyhow::Result; diff --git a/src/commands/completions.rs b/src/commands/completions.rs index 8705d6837..3b1ececff 100644 --- a/src/commands/completions.rs +++ b/src/commands/completions.rs @@ -6,7 +6,7 @@ use std::io::Write; use clap::CommandFactory; -use clap_complete::{generate, shells, Generator}; +use clap_complete::{Generator, generate, shells}; /// `completions` subcommand #[derive(clap::Parser, Command, Debug)] diff --git a/src/commands/config.rs b/src/commands/config.rs index 5d3481885..038fb004b 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -1,6 +1,6 @@ //! `config` subcommand -use crate::{status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; diff --git a/src/commands/copy.rs b/src/commands/copy.rs index b5f8bd0a6..7f9bd5afa 100644 --- a/src/commands/copy.rs +++ b/src/commands/copy.rs @@ -1,18 +1,19 @@ //! `copy` subcommand use crate::{ + Application, RUSTIC_APP, RusticConfig, commands::init::init_password, helpers::table_with_titles, repository::{CliIndexedRepo, CliRepo}, - status_err, Application, RusticConfig, RUSTIC_APP, + status_err, }; -use abscissa_core::{config::Override, Command, FrameworkError, Runnable, Shutdown}; -use anyhow::{bail, Result}; +use abscissa_core::{Command, FrameworkError, Runnable, Shutdown, config::Override}; +use anyhow::{Result, bail}; use conflate::Merge; -use log::{error, info, log, Level}; +use log::{Level, error, info, log}; use serde::{Deserialize, Serialize}; -use rustic_core::{repofile::SnapshotFile, CopySnapshot, Id, KeyOptions}; +use rustic_core::{CopySnapshot, Id, KeyOptions, repofile::SnapshotFile}; /// `copy` subcommand #[derive(clap::Parser, Command, Default, Clone, Debug, Serialize, Deserialize, Merge)] @@ -58,7 +59,9 @@ impl Runnable for CopyCmd { fn run(&self) { let config = RUSTIC_APP.config(); if config.copy.targets.is_empty() { - status_err!("No target given. Please specify at least 1 target either in the profile or using --target!"); + status_err!( + "No target given. Please specify at least 1 target either in the profile or using --target!" + ); RUSTIC_APP.shutdown(Shutdown::Crash); } if let Err(err) = config.repository.run_indexed(|repo| self.inner_run(repo)) { @@ -118,7 +121,9 @@ impl CopyCmd { }; if repo.config().poly()? != target_repo.config().poly()? { - bail!("cannot copy to repository with different chunker parameter (re-chunking not implemented)!"); + bail!( + "cannot copy to repository with different chunker parameter (re-chunking not implemented)!" + ); } let snaps = target_repo.relevant_copy_snapshots( diff --git a/src/commands/diff.rs b/src/commands/diff.rs index 5333ba9c9..29306635d 100644 --- a/src/commands/diff.rs +++ b/src/commands/diff.rs @@ -1,6 +1,6 @@ //! `diff` subcommand -use crate::{repository::CliIndexedRepo, status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, repository::CliIndexedRepo, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; use clap::ValueHint; @@ -11,12 +11,12 @@ use std::{ path::{Path, PathBuf}, }; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use rustic_core::{ - repofile::{Node, NodeType}, IndexedFull, LocalDestination, LocalSource, LocalSourceFilterOptions, LocalSourceSaveOptions, LsOptions, ReadSource, ReadSourceEntry, Repository, RusticResult, + repofile::{Node, NodeType}, }; /// `diff` subcommand diff --git a/src/commands/docs.rs b/src/commands/docs.rs index 03460ce9e..2ffffd0dc 100644 --- a/src/commands/docs.rs +++ b/src/commands/docs.rs @@ -1,12 +1,12 @@ //! `docs` subcommand -use abscissa_core::{status_err, Application, Command, Runnable, Shutdown}; +use abscissa_core::{Application, Command, Runnable, Shutdown, status_err}; use anyhow::Result; use clap::Subcommand; use crate::{ - application::constants::{RUSTIC_CONFIG_DOCS_URL, RUSTIC_DEV_DOCS_URL, RUSTIC_DOCS_URL}, RUSTIC_APP, + application::constants::{RUSTIC_CONFIG_DOCS_URL, RUSTIC_DEV_DOCS_URL, RUSTIC_DOCS_URL}, }; #[derive(Command, Debug, Clone, Copy, Default, Subcommand, Runnable)] diff --git a/src/commands/dump.rs b/src/commands/dump.rs index fdf8c40c8..b1f78b25a 100644 --- a/src/commands/dump.rs +++ b/src/commands/dump.rs @@ -2,24 +2,24 @@ use std::{ fs::File, - io::{copy, Cursor, Read, Seek, SeekFrom, Write}, + io::{Cursor, Read, Seek, SeekFrom, Write, copy}, path::PathBuf, }; -use crate::{repository::CliIndexedRepo, status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, repository::CliIndexedRepo, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; use anyhow::Result; use derive_more::FromStr; -use flate2::{write::GzEncoder, Compression}; +use flate2::{Compression, write::GzEncoder}; use log::warn; use rustic_core::{ + LsOptions, repofile::{Node, NodeType}, vfs::OpenFile, - LsOptions, }; use tar::{Builder, EntryType, Header}; -use zip::{write::SimpleFileOptions, ZipWriter}; +use zip::{ZipWriter, write::SimpleFileOptions}; /// `dump` subcommand #[derive(clap::Parser, Command, Debug)] diff --git a/src/commands/find.rs b/src/commands/find.rs index 942efdfe5..66eb5b044 100644 --- a/src/commands/find.rs +++ b/src/commands/find.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; -use crate::{repository::CliIndexedRepo, status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, repository::CliIndexedRepo, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; use anyhow::Result; @@ -11,8 +11,8 @@ use globset::{Glob, GlobBuilder, GlobSetBuilder}; use itertools::Itertools; use rustic_core::{ - repofile::{Node, SnapshotFile}, FindMatches, FindNode, SnapshotGroupCriterion, + repofile::{Node, SnapshotFile}, }; use super::ls::print_node; diff --git a/src/commands/forget.rs b/src/commands/forget.rs index f95bdb473..f3e48e411 100644 --- a/src/commands/forget.rs +++ b/src/commands/forget.rs @@ -1,16 +1,16 @@ //! `forget` subcommand use crate::repository::CliOpenRepo; -use crate::{helpers::table_with_titles, status_err, Application, RusticConfig, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, RusticConfig, helpers::table_with_titles, status_err}; -use abscissa_core::{config::Override, Shutdown}; use abscissa_core::{Command, FrameworkError, Runnable}; +use abscissa_core::{Shutdown, config::Override}; use anyhow::Result; use chrono::Local; use conflate::Merge; use serde::{Deserialize, Serialize}; -use serde_with::{serde_as, DisplayFromStr}; +use serde_with::{DisplayFromStr, serde_as}; use crate::{commands::prune::PruneCmd, filtering::SnapshotFilter}; diff --git a/src/commands/init.rs b/src/commands/init.rs index 6bfa9bb19..f12e5e915 100644 --- a/src/commands/init.rs +++ b/src/commands/init.rs @@ -1,10 +1,10 @@ //! `init` subcommand -use abscissa_core::{status_err, Command, Runnable, Shutdown}; -use anyhow::{bail, Result}; +use abscissa_core::{Command, Runnable, Shutdown, status_err}; +use anyhow::{Result, bail}; use dialoguer::Password; -use crate::{repository::CliRepo, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, repository::CliRepo}; use rustic_core::{ConfigOptions, KeyOptions, OpenStatus, Repository}; diff --git a/src/commands/key.rs b/src/commands/key.rs index 47eda0ef1..44697a9ba 100644 --- a/src/commands/key.rs +++ b/src/commands/key.rs @@ -1,6 +1,6 @@ //! `key` subcommand -use crate::{repository::CliOpenRepo, status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, repository::CliOpenRepo, status_err}; use std::path::PathBuf; diff --git a/src/commands/list.rs b/src/commands/list.rs index 79ddc728a..7b208e2e5 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -2,10 +2,10 @@ use std::num::NonZero; -use crate::{repository::CliOpenRepo, status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, repository::CliOpenRepo, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use rustic_core::repofile::{IndexFile, IndexId, KeyId, PackId, SnapshotId}; diff --git a/src/commands/ls.rs b/src/commands/ls.rs index 41d04df1e..a89fab2e1 100644 --- a/src/commands/ls.rs +++ b/src/commands/ls.rs @@ -2,14 +2,14 @@ use std::path::Path; -use crate::{repository::CliIndexedRepo, status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, repository::CliIndexedRepo, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; use anyhow::Result; use rustic_core::{ - repofile::{Node, NodeType}, LsOptions, + repofile::{Node, NodeType}, }; mod constants { diff --git a/src/commands/merge.rs b/src/commands/merge.rs index bb1525e03..f5bd45f45 100644 --- a/src/commands/merge.rs +++ b/src/commands/merge.rs @@ -1,13 +1,13 @@ //! `merge` subcommand -use crate::{repository::CliOpenRepo, status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, repository::CliOpenRepo, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; use anyhow::Result; use log::info; use chrono::Local; -use rustic_core::{last_modified_node, repofile::SnapshotFile, SnapshotOptions}; +use rustic_core::{SnapshotOptions, last_modified_node, repofile::SnapshotFile}; /// `merge` subcommand #[derive(clap::Parser, Default, Command, Debug)] diff --git a/src/commands/mount.rs b/src/commands/mount.rs index bfed98501..4498115a8 100644 --- a/src/commands/mount.rs +++ b/src/commands/mount.rs @@ -7,16 +7,16 @@ mod fusefs; use fusefs::FuseFS; use abscissa_core::{ - config::Override, Command, FrameworkError, FrameworkErrorKind::ParseError, Runnable, Shutdown, + Command, FrameworkError, FrameworkErrorKind::ParseError, Runnable, Shutdown, config::Override, }; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use conflate::{Merge, MergeFrom}; -use fuse_mt::{mount, FuseMT}; +use fuse_mt::{FuseMT, mount}; use rustic_core::vfs::{FilePolicy, IdenticalSnapshot, Latest, Vfs}; use std::{ffi::OsStr, path::PathBuf}; -use crate::{repository::CliIndexedRepo, status_err, Application, RusticConfig, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, RusticConfig, repository::CliIndexedRepo, status_err}; #[derive(Clone, Debug, Default, Command, Parser, Merge, serde::Serialize, serde::Deserialize)] #[serde(default, rename_all = "kebab-case", deny_unknown_fields)] diff --git a/src/commands/mount/fusefs.rs b/src/commands/mount/fusefs.rs index eb2f4d185..e65f10aa7 100644 --- a/src/commands/mount/fusefs.rs +++ b/src/commands/mount/fusefs.rs @@ -9,9 +9,9 @@ use std::{ }; use rustic_core::{ + IndexedFull, Repository, repofile::{Node, NodeType}, vfs::{FilePolicy, OpenFile, Vfs}, - IndexedFull, Repository, }; use fuse_mt::{ diff --git a/src/commands/prune.rs b/src/commands/prune.rs index 5fcc6f7bc..698131933 100644 --- a/src/commands/prune.rs +++ b/src/commands/prune.rs @@ -1,7 +1,7 @@ //! `prune` subcommand use crate::{ - helpers::bytes_size_to_string, repository::CliOpenRepo, status_err, Application, RUSTIC_APP, + Application, RUSTIC_APP, helpers::bytes_size_to_string, repository::CliOpenRepo, status_err, }; use abscissa_core::{Command, Runnable, Shutdown}; use log::debug; diff --git a/src/commands/repair.rs b/src/commands/repair.rs index b5242b7a1..9bf57d3f4 100644 --- a/src/commands/repair.rs +++ b/src/commands/repair.rs @@ -1,8 +1,9 @@ //! `repair` subcommand use crate::{ + Application, RUSTIC_APP, repository::{CliIndexedRepo, CliOpenRepo}, - status_err, Application, RUSTIC_APP, + status_err, }; use abscissa_core::{Command, Runnable, Shutdown}; diff --git a/src/commands/repoinfo.rs b/src/commands/repoinfo.rs index 5dcf686a2..e9b5c88f3 100644 --- a/src/commands/repoinfo.rs +++ b/src/commands/repoinfo.rs @@ -1,9 +1,10 @@ //! `repoinfo` subcommand use crate::{ + Application, RUSTIC_APP, helpers::{bytes_size_to_string, table_right_from}, repository::CliRepo, - status_err, Application, RUSTIC_APP, + status_err, }; use abscissa_core::{Command, Runnable, Shutdown}; diff --git a/src/commands/restore.rs b/src/commands/restore.rs index b651a24aa..6478303e9 100644 --- a/src/commands/restore.rs +++ b/src/commands/restore.rs @@ -1,7 +1,7 @@ //! `restore` subcommand use crate::{ - helpers::bytes_size_to_string, repository::CliIndexedRepo, status_err, Application, RUSTIC_APP, + Application, RUSTIC_APP, helpers::bytes_size_to_string, repository::CliIndexedRepo, status_err, }; use abscissa_core::{Command, Runnable, Shutdown}; diff --git a/src/commands/self_update.rs b/src/commands/self_update.rs index f9540e44e..d4969f2e6 100644 --- a/src/commands/self_update.rs +++ b/src/commands/self_update.rs @@ -2,7 +2,7 @@ use crate::{Application, RUSTIC_APP}; -use abscissa_core::{status_err, Command, Runnable, Shutdown}; +use abscissa_core::{Command, Runnable, Shutdown, status_err}; use anyhow::Result; diff --git a/src/commands/show_config.rs b/src/commands/show_config.rs index 84d8ee9a4..d47d67bbf 100644 --- a/src/commands/show_config.rs +++ b/src/commands/show_config.rs @@ -1,6 +1,6 @@ //! `show-config` subcommand -use crate::{status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; use anyhow::Result; diff --git a/src/commands/snapshots.rs b/src/commands/snapshots.rs index 27fb8a3e7..988370c88 100644 --- a/src/commands/snapshots.rs +++ b/src/commands/snapshots.rs @@ -1,9 +1,10 @@ //! `smapshot` subcommand use crate::{ + Application, RUSTIC_APP, helpers::{bold_cell, bytes_size_to_string, table, table_right_from}, repository::CliOpenRepo, - status_err, Application, RUSTIC_APP, + status_err, }; use abscissa_core::{Command, Runnable, Shutdown}; @@ -13,8 +14,8 @@ use humantime::format_duration; use itertools::Itertools; use rustic_core::{ - repofile::{DeleteOption, SnapshotFile}, SnapshotGroupCriterion, + repofile::{DeleteOption, SnapshotFile}, }; #[cfg(feature = "tui")] diff --git a/src/commands/tag.rs b/src/commands/tag.rs index 302c58123..cb3af9723 100644 --- a/src/commands/tag.rs +++ b/src/commands/tag.rs @@ -1,13 +1,13 @@ //! `tag` subcommand -use crate::{repository::CliOpenRepo, status_err, Application, RUSTIC_APP}; +use crate::{Application, RUSTIC_APP, repository::CliOpenRepo, status_err}; use abscissa_core::{Command, Runnable, Shutdown}; use anyhow::Result; use chrono::{Duration, Local}; -use rustic_core::{repofile::DeleteOption, StringList}; +use rustic_core::{StringList, repofile::DeleteOption}; /// `tag` subcommand #[derive(clap::Parser, Command, Debug)] diff --git a/src/commands/tui.rs b/src/commands/tui.rs index d62e51117..dbc022d40 100644 --- a/src/commands/tui.rs +++ b/src/commands/tui.rs @@ -20,7 +20,7 @@ use anyhow::Result; use crossterm::{ event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode, KeyEventKind}, execute, - terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, + terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode}, }; use ratatui::prelude::*; use rustic_core::{IndexedFull, Progress, ProgressBars, SnapshotGroupCriterion}; diff --git a/src/commands/tui/ls.rs b/src/commands/tui/ls.rs index 2240e4ada..e0b0b7e2c 100644 --- a/src/commands/tui/ls.rs +++ b/src/commands/tui/ls.rs @@ -7,9 +7,9 @@ use ratatui::{ widgets::{Block, Borders, Paragraph}, }; use rustic_core::{ + IndexedFull, ProgressBars, Repository, repofile::{Node, SnapshotFile, Tree}, vfs::OpenFile, - IndexedFull, ProgressBars, Repository, }; use style::palette::tailwind; @@ -18,8 +18,8 @@ use crate::commands::{ tui::{ restore::Restore, widgets::{ - popup_prompt, popup_scrollable_text, popup_text, Draw, PopUpPrompt, PopUpText, - ProcessEvent, PromptResult, SelectTable, TextInputResult, WithBlock, + Draw, PopUpPrompt, PopUpText, ProcessEvent, PromptResult, SelectTable, TextInputResult, + WithBlock, popup_prompt, popup_scrollable_text, popup_text, }, }, }; @@ -35,8 +35,7 @@ enum CurrentScreen<'a, P, S> { ShowFile(PopUpInput), } -const INFO_TEXT: &str = - "(Esc) quit | (Enter) enter dir | (Backspace) return to parent | (v) view | (r) restore | (?) show all commands"; +const INFO_TEXT: &str = "(Esc) quit | (Enter) enter dir | (Backspace) return to parent | (v) view | (r) restore | (?) show all commands"; const HELP_TEXT: &str = r" General Commands: diff --git a/src/commands/tui/progress.rs b/src/commands/tui/progress.rs index 3ceca7f67..2c3dbe8dc 100644 --- a/src/commands/tui/progress.rs +++ b/src/commands/tui/progress.rs @@ -3,10 +3,10 @@ use std::sync::{Arc, RwLock}; use std::time::{Duration, SystemTime}; use bytesize::ByteSize; -use ratatui::{backend::CrosstermBackend, Terminal}; +use ratatui::{Terminal, backend::CrosstermBackend}; use rustic_core::{Progress, ProgressBars}; -use super::widgets::{popup_gauge, popup_text, Draw}; +use super::widgets::{Draw, popup_gauge, popup_text}; #[derive(Clone)] pub struct TuiProgressBars { diff --git a/src/commands/tui/restore.rs b/src/commands/tui/restore.rs index 879ab1f38..0994ebe05 100644 --- a/src/commands/tui/restore.rs +++ b/src/commands/tui/restore.rs @@ -2,14 +2,14 @@ use anyhow::Result; use crossterm::event::{Event, KeyCode, KeyEventKind}; use ratatui::prelude::*; use rustic_core::{ - repofile::Node, IndexedFull, LocalDestination, LsOptions, ProgressBars, Repository, - RestoreOptions, RestorePlan, + IndexedFull, LocalDestination, LsOptions, ProgressBars, Repository, RestoreOptions, + RestorePlan, repofile::Node, }; use crate::{ commands::tui::widgets::{ - popup_input, popup_prompt, Draw, PopUpInput, PopUpPrompt, PopUpText, ProcessEvent, - PromptResult, TextInputResult, + Draw, PopUpInput, PopUpPrompt, PopUpText, ProcessEvent, PromptResult, TextInputResult, + popup_input, popup_prompt, }, helpers::bytes_size_to_string, }; diff --git a/src/commands/tui/snapshots.rs b/src/commands/tui/snapshots.rs index 3c01e1250..659060d45 100644 --- a/src/commands/tui/snapshots.rs +++ b/src/commands/tui/snapshots.rs @@ -9,8 +9,8 @@ use ratatui::{ widgets::{Block, Borders, Paragraph}, }; use rustic_core::{ - repofile::{DeleteOption, SnapshotFile}, IndexedFull, ProgressBars, Repository, SnapshotGroup, SnapshotGroupCriterion, StringList, + repofile::{DeleteOption, SnapshotFile}, }; use style::palette::tailwind; @@ -21,9 +21,9 @@ use crate::{ ls::{Snapshot, SnapshotResult}, tree::{Tree, TreeIterItem, TreeNode}, widgets::{ - popup_input, popup_prompt, popup_table, popup_text, Draw, PopUpInput, PopUpPrompt, - PopUpTable, PopUpText, ProcessEvent, PromptResult, SelectTable, TextInputResult, - WithBlock, + Draw, PopUpInput, PopUpPrompt, PopUpTable, PopUpText, ProcessEvent, PromptResult, + SelectTable, TextInputResult, WithBlock, popup_input, popup_prompt, popup_table, + popup_text, }, }, }, @@ -74,8 +74,7 @@ enum SnapshotNode { Snap(usize), } -const INFO_TEXT: &str = - "(Esc) quit | (F5) reload snapshots | (Enter) show contents | (v) toggle view | (i) show snapshot | (?) show all commands"; +const INFO_TEXT: &str = "(Esc) quit | (F5) reload snapshots | (Enter) show contents | (v) toggle view | (i) show snapshot | (?) show all commands"; const HELP_TEXT: &str = r"General Commands: q, Esc : exit @@ -721,7 +720,7 @@ impl<'a, P: ProgressBars, S: IndexedFull> Snapshots<'a, P, S> { } pub fn input(&mut self, event: Event) -> Result { - use KeyCode::{Char, Enter, Esc, Left, Right, F}; + use KeyCode::{Char, Enter, Esc, F, Left, Right}; match &mut self.current_screen { CurrentScreen::Snapshots => { match event { diff --git a/src/commands/tui/widgets/select_table.rs b/src/commands/tui/widgets/select_table.rs index bc09a3926..8a41b58b1 100644 --- a/src/commands/tui/widgets/select_table.rs +++ b/src/commands/tui/widgets/select_table.rs @@ -1,7 +1,7 @@ use super::{ - layout, style, Color, Constraint, Draw, Event, Frame, KeyCode, KeyEventKind, Layout, Modifier, - ProcessEvent, Rect, Row, Scrollbar, ScrollbarOrientation, ScrollbarState, SizedWidget, Style, - Stylize, Table, TableState, Text, + Color, Constraint, Draw, Event, Frame, KeyCode, KeyEventKind, Layout, Modifier, ProcessEvent, + Rect, Row, Scrollbar, ScrollbarOrientation, ScrollbarState, SizedWidget, Style, Stylize, Table, + TableState, Text, layout, style, }; use std::iter::once; use style::palette::tailwind; diff --git a/src/commands/tui/widgets/text_input.rs b/src/commands/tui/widgets/text_input.rs index 7f987bc6c..b4b8dbd11 100644 --- a/src/commands/tui/widgets/text_input.rs +++ b/src/commands/tui/widgets/text_input.rs @@ -69,7 +69,7 @@ impl ProcessEvent for TextInput { } else { match (code, modifiers) { (KeyCode::Esc | KeyCode::Enter | KeyCode::Char('q' | 'x'), _) => { - return TextInputResult::Cancel + return TextInputResult::Cancel; } (KeyCode::Home, _) => { self.textarea.move_cursor(CursorMove::Top); diff --git a/src/commands/tui/widgets/with_block.rs b/src/commands/tui/widgets/with_block.rs index d6279072e..e2cbf2b80 100644 --- a/src/commands/tui/widgets/with_block.rs +++ b/src/commands/tui/widgets/with_block.rs @@ -1,4 +1,4 @@ -use super::{layout, Block, Draw, Event, Frame, ProcessEvent, Rect, SizedWidget}; +use super::{Block, Draw, Event, Frame, ProcessEvent, Rect, SizedWidget, layout}; use layout::Size; pub struct WithBlock { diff --git a/src/commands/webdav.rs b/src/commands/webdav.rs index 90b79072c..c1e431119 100644 --- a/src/commands/webdav.rs +++ b/src/commands/webdav.rs @@ -5,11 +5,11 @@ use std::net::ToSocketAddrs; -use crate::{repository::CliIndexedRepo, status_err, Application, RusticConfig, RUSTIC_APP}; -use abscissa_core::{config::Override, Command, FrameworkError, Runnable, Shutdown}; -use anyhow::{anyhow, Result}; +use crate::{Application, RUSTIC_APP, RusticConfig, repository::CliIndexedRepo, status_err}; +use abscissa_core::{Command, FrameworkError, Runnable, Shutdown, config::Override}; +use anyhow::{Result, anyhow}; use conflate::Merge; -use dav_server::{warp::dav_handler, DavHandler}; +use dav_server::{DavHandler, warp::dav_handler}; use serde::{Deserialize, Serialize}; use rustic_core::vfs::{FilePolicy, IdenticalSnapshot, Latest, Vfs}; diff --git a/src/commands/webdav/webdavfs.rs b/src/commands/webdav/webdavfs.rs index ae5f02a7c..db68fb54b 100644 --- a/src/commands/webdav/webdavfs.rs +++ b/src/commands/webdav/webdavfs.rs @@ -17,9 +17,9 @@ use dav_server::{ }; use futures::FutureExt; use rustic_core::{ + IndexedFull, Repository, repofile::Node, vfs::{FilePolicy, OpenFile, Vfs}, - IndexedFull, Repository, }; use tokio::task::spawn_blocking; diff --git a/src/config.rs b/src/config.rs index 97147c9a5..8fdc26e54 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,16 +13,16 @@ use std::{ path::PathBuf, }; -use abscissa_core::{config::Config, path::AbsPathBuf, FrameworkError}; -use anyhow::{anyhow, bail, Result}; +use abscissa_core::{FrameworkError, config::Config, path::AbsPathBuf}; +use anyhow::{Result, anyhow, bail}; use clap::{Parser, ValueHint}; use conflate::Merge; use directories::ProjectDirs; use itertools::Itertools; -use log::{debug, Level}; +use log::{Level, debug}; use reqwest::Url; use serde::{Deserialize, Serialize}; -use serde_with::{serde_as, DisplayFromStr}; +use serde_with::{DisplayFromStr, serde_as}; #[cfg(not(all(feature = "mount", feature = "webdav")))] use toml::Value; @@ -239,7 +239,7 @@ impl GlobalOptions { pub fn push_metrics(&self, job_name: &str, labels: BTreeMap) -> Result<()> { use prometheus::{Encoder, ProtobufEncoder}; - use reqwest::{blocking::Client, header::CONTENT_TYPE, StatusCode}; + use reqwest::{StatusCode, blocking::Client, header::CONTENT_TYPE}; // only move on if a prometheus push url is given let Some(url) = &self.prometheus else { @@ -437,7 +437,10 @@ mod tests { .collect(); let (url, _) = make_url_and_encoded_metrics(&Url::from_str("http://host")?, "test_job", grouping)?; - assert_eq!(url.to_string(), "http://host/metrics/job@base64/dGVzdF9qb2I/abc@base64/eHl6/path@base64/L215L3BhdGg/tags@base64/YSxiLGNkZQ"); + assert_eq!( + url.to_string(), + "http://host/metrics/job@base64/dGVzdF9qb2I/abc@base64/eHl6/path@base64/L215L3BhdGg/tags@base64/YSxiLGNkZQ" + ); Ok(()) } } diff --git a/src/config/progress_options.rs b/src/config/progress_options.rs index 3f24f1489..119e17ebe 100644 --- a/src/config/progress_options.rs +++ b/src/config/progress_options.rs @@ -8,7 +8,7 @@ use clap::Parser; use conflate::Merge; use serde::{Deserialize, Serialize}; -use serde_with::{serde_as, DisplayFromStr}; +use serde_with::{DisplayFromStr, serde_as}; use rustic_core::{Progress, ProgressBars}; diff --git a/src/filtering.rs b/src/filtering.rs index eda6414a7..73874fda2 100644 --- a/src/filtering.rs +++ b/src/filtering.rs @@ -13,7 +13,7 @@ use anyhow::{anyhow, bail}; use bytesize::ByteSize; use derive_more::derive::Display; use log::warn; -use rustic_core::{repofile::SnapshotFile, StringList}; +use rustic_core::{StringList, repofile::SnapshotFile}; use cached::proc_macro::cached; use chrono::{DateTime, Local, NaiveTime}; @@ -21,17 +21,17 @@ use conflate::Merge; #[cfg(feature = "jq")] use jaq_core::{ - load::{Arena, File, Loader}, Compiler, Ctx, Filter, Native, RcIter, + load::{Arena, File, Loader}, }; #[cfg(feature = "jq")] use jaq_json::Val; #[cfg(feature = "rhai")] -use rhai::{serde::to_dynamic, Dynamic, Engine, FnPtr, AST}; +use rhai::{AST, Dynamic, Engine, FnPtr, serde::to_dynamic}; use serde::{Deserialize, Serialize}; #[cfg(feature = "jq")] use serde_json::Value; -use serde_with::{serde_as, DisplayFromStr}; +use serde_with::{DisplayFromStr, serde_as}; /// A function to filter snapshots /// diff --git a/src/helpers.rs b/src/helpers.rs index 9d752d6df..3ae81e6f8 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,6 +1,6 @@ use bytesize::ByteSize; use comfy_table::{ - presets::ASCII_MARKDOWN, Attribute, Cell, CellAlignment, ContentArrangement, Table, + Attribute, Cell, CellAlignment, ContentArrangement, Table, presets::ASCII_MARKDOWN, }; /// Helpers for table output diff --git a/src/lib.rs b/src/lib.rs index 5efe928e4..aeed73ae9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,6 @@ Application based on the [Abscissa] framework. [Abscissa]: https://github.com/iqlusioninc/abscissa */ -#![forbid(unsafe_code)] #![warn( // unreachable_pub, // frequently check // TODO: Activate and create better docs diff --git a/src/repository.rs b/src/repository.rs index 7f045078e..91a5f3dd4 100644 --- a/src/repository.rs +++ b/src/repository.rs @@ -8,7 +8,7 @@ use std::fmt::Debug; use std::ops::Deref; use abscissa_core::Application; -use anyhow::{anyhow, bail, Result}; +use anyhow::{Result, anyhow, bail}; use clap::Parser; use conflate::Merge; use dialoguer::Password; @@ -19,8 +19,8 @@ use rustic_core::{ use serde::{Deserialize, Serialize}; use crate::{ - config::{hooks::Hooks, progress_options::ProgressOptions}, RUSTIC_APP, + config::{hooks::Hooks, progress_options::ProgressOptions}, }; pub(super) mod constants { diff --git a/tests/backup_restore.rs b/tests/backup_restore.rs index b5803833e..6066336cd 100644 --- a/tests/backup_restore.rs +++ b/tests/backup_restore.rs @@ -8,10 +8,10 @@ //! `cargo nextest run -E 'test(backup)'`. use dircmp::Comparison; -use tempfile::{tempdir, TempDir}; +use tempfile::{TempDir, tempdir}; use assert_cmd::Command; -use predicates::prelude::{predicate, PredicateBooleanExt}; +use predicates::prelude::{PredicateBooleanExt, predicate}; mod repositories; use repositories::src_snapshot; diff --git a/tests/hooks.rs b/tests/hooks.rs index 897f32c14..860dbc0d4 100644 --- a/tests/hooks.rs +++ b/tests/hooks.rs @@ -16,7 +16,7 @@ use abscissa_core::fs::remove_file; use assert_cmd::Command; use predicates::prelude::predicate; use rstest::{fixture, rstest}; -use tempfile::{tempdir, TempDir}; +use tempfile::{TempDir, tempdir}; use rustic_testing::TestResult; #[fixture] diff --git a/tests/repositories.rs b/tests/repositories.rs index 15ab68b3d..0e6a73a4c 100644 --- a/tests/repositories.rs +++ b/tests/repositories.rs @@ -5,7 +5,7 @@ use rstest::{fixture, rstest}; use rustic_testing::TestResult; use std::{fs::File, path::Path}; use tar::Archive; -use tempfile::{tempdir, TempDir}; +use tempfile::{TempDir, tempdir}; #[derive(Debug)] pub struct TestSource(TempDir);