cargo fmt, rearranging use statements
by setting `group_imports = "StdExternalCrate"` in `rustfmt.toml`, cargo fmt/rustfmt rearranges your use statements into three groups: - std/core/alloc, - followed by external crates, - followed by self/super/crate
This commit is contained in:
parent
da998d019a
commit
8a7cbca461
7 changed files with 33 additions and 28 deletions
|
@ -2,4 +2,5 @@ max_width = 120
|
||||||
fn_single_line = true
|
fn_single_line = true
|
||||||
hard_tabs = true
|
hard_tabs = true
|
||||||
tab_spaces = 2
|
tab_spaces = 2
|
||||||
newline_style = "Unix"
|
newline_style = "Unix"
|
||||||
|
group_imports = "StdExternalCrate"
|
10
src/files.rs
10
src/files.rs
|
@ -1,8 +1,3 @@
|
||||||
use crate::findings::{Findings, ScanError};
|
|
||||||
use crate::mime_db::MimeDb;
|
|
||||||
use crate::parameters::ScanOpts;
|
|
||||||
use crate::{String, MIMEDB};
|
|
||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -17,6 +12,11 @@ use mime::Mime;
|
||||||
use mime_guess::from_ext;
|
use mime_guess::from_ext;
|
||||||
use walkdir::{DirEntry, WalkDir};
|
use walkdir::{DirEntry, WalkDir};
|
||||||
|
|
||||||
|
use crate::findings::{Findings, ScanError};
|
||||||
|
use crate::mime_db::MimeDb;
|
||||||
|
use crate::parameters::ScanOpts;
|
||||||
|
use crate::{String, MIMEDB};
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(windows)] {
|
if #[cfg(windows)] {
|
||||||
/// Determines whether or not a file is hidden by checking its win32 file attributes.
|
/// Determines whether or not a file is hidden by checking its win32 file attributes.
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
|
use std::fmt::{Display, Formatter};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
|
#[cfg(feature = "json")]
|
||||||
|
use serde::{ser::SerializeStruct, Serializer};
|
||||||
|
|
||||||
use crate::files::mime_extension_lookup;
|
use crate::files::mime_extension_lookup;
|
||||||
use crate::String;
|
use crate::String;
|
||||||
|
|
||||||
#[cfg(feature = "json")]
|
|
||||||
use serde::{ser::SerializeStruct, Serializer};
|
|
||||||
use std::fmt::{Display, Formatter};
|
|
||||||
|
|
||||||
/// Information about a scanned file.
|
/// Information about a scanned file.
|
||||||
#[derive(Ord, PartialOrd, Eq, PartialEq)]
|
#[derive(Ord, PartialOrd, Eq, PartialEq)]
|
||||||
pub struct Findings {
|
pub struct Findings {
|
||||||
|
|
|
@ -8,12 +8,12 @@ pub mod mime_db;
|
||||||
pub mod parameters;
|
pub mod parameters;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
use crate::findings::Findings;
|
|
||||||
use crate::mime_db::MimeDb;
|
|
||||||
|
|
||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
|
|
||||||
|
use crate::findings::Findings;
|
||||||
|
use crate::mime_db::MimeDb;
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(not(all(target_endian = "big", target_pointer_width = "32")))] {
|
if #[cfg(not(all(target_endian = "big", target_pointer_width = "32")))] {
|
||||||
// most architectures
|
// most architectures
|
||||||
|
|
|
@ -21,13 +21,12 @@ use std::io::{stdout, BufWriter, Write};
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
use clap::Clap;
|
use clap::Clap;
|
||||||
use log::{debug, error, info, trace, warn, Level};
|
|
||||||
|
|
||||||
use fif::files::{scan_directory, scan_from_walkdir};
|
use fif::files::{scan_directory, scan_from_walkdir};
|
||||||
use fif::formats::Format;
|
use fif::formats::Format;
|
||||||
use fif::parameters::OutputFormat;
|
use fif::parameters::OutputFormat;
|
||||||
use fif::utils::{clap_long_version, os_name};
|
use fif::utils::{clap_long_version, os_name};
|
||||||
use fif::{formats, init_db, parameters};
|
use fif::{formats, init_db, parameters};
|
||||||
|
use log::{debug, error, info, trace, warn, Level};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
//! [Clap] struct used to parse command line arguments.
|
//! [Clap] struct used to parse command line arguments.
|
||||||
|
|
||||||
|
use std::collections::BTreeSet;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use cfg_if::cfg_if;
|
||||||
|
use clap::{AppSettings, Clap};
|
||||||
|
|
||||||
use crate::utils::{clap_long_version, clap_version};
|
use crate::utils::{clap_long_version, clap_version};
|
||||||
use crate::String as StringType;
|
use crate::String as StringType;
|
||||||
use cfg_if::cfg_if;
|
|
||||||
use clap::{AppSettings, Clap};
|
|
||||||
use std::collections::BTreeSet;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
if #[cfg(windows)] {
|
if #[cfg(windows)] {
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::ffi::OsStr;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use clap::Clap;
|
||||||
use fif::files::{mime_extension_lookup, BUF_SIZE};
|
use fif::files::{mime_extension_lookup, BUF_SIZE};
|
||||||
use fif::files::{scan_directory, scan_from_walkdir};
|
use fif::files::{scan_directory, scan_from_walkdir};
|
||||||
use fif::findings::Findings;
|
use fif::findings::Findings;
|
||||||
use fif::formats::{Format, PowerShell, Shell};
|
use fif::formats::{Format, PowerShell, Shell};
|
||||||
use fif::mime_db::MimeDb;
|
use fif::mime_db::MimeDb;
|
||||||
use fif::String;
|
use fif::String;
|
||||||
|
|
||||||
use crate::parameters::Parameters;
|
|
||||||
use clap::Clap;
|
|
||||||
use mime::{Mime, APPLICATION_OCTET_STREAM, APPLICATION_PDF, IMAGE_JPEG, IMAGE_PNG};
|
use mime::{Mime, APPLICATION_OCTET_STREAM, APPLICATION_PDF, IMAGE_JPEG, IMAGE_PNG};
|
||||||
|
|
||||||
use crate::parameters::ExtensionSet;
|
use crate::parameters::ExtensionSet;
|
||||||
use std::collections::HashMap;
|
use crate::parameters::Parameters;
|
||||||
use std::ffi::OsStr;
|
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
|
|
||||||
const JPEG_BYTES: &[u8] = b"\xFF\xD8\xFF";
|
const JPEG_BYTES: &[u8] = b"\xFF\xD8\xFF";
|
||||||
const PNG_BYTES: &[u8] = b"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A";
|
const PNG_BYTES: &[u8] = b"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A";
|
||||||
|
@ -84,13 +84,15 @@ fn recommend_ext() {
|
||||||
/// Create a simple directory with some files, run `scan_directory` on it, and ensure that the files have their
|
/// Create a simple directory with some files, run `scan_directory` on it, and ensure that the files have their
|
||||||
/// associated mime types correctly deduced.
|
/// associated mime types correctly deduced.
|
||||||
fn simple_directory() {
|
fn simple_directory() {
|
||||||
use crate::parameters::ScanOpts;
|
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::env::set_current_dir;
|
use std::env::set_current_dir;
|
||||||
use std::fs::{canonicalize, File};
|
use std::fs::{canonicalize, File};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
|
use crate::parameters::ScanOpts;
|
||||||
|
|
||||||
// set of files to scan. all but the last files have magic numbers corresponding to their extension, except for
|
// set of files to scan. all but the last files have magic numbers corresponding to their extension, except for
|
||||||
// "wrong.jpg", which is actually a png.
|
// "wrong.jpg", which is actually a png.
|
||||||
let mut files = HashMap::new();
|
let mut files = HashMap::new();
|
||||||
|
@ -379,8 +381,9 @@ fn outputs_move_commands() {
|
||||||
#[cfg(feature = "json")]
|
#[cfg(feature = "json")]
|
||||||
/// Ensure JSON output is valid.
|
/// Ensure JSON output is valid.
|
||||||
fn test_json() {
|
fn test_json() {
|
||||||
use crate::formats::Json;
|
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
|
use crate::formats::Json;
|
||||||
// create an example finding stating that "misnamed_file.png" has been identified as a jpeg file
|
// create an example finding stating that "misnamed_file.png" has been identified as a jpeg file
|
||||||
let entries = vec![Ok(Findings {
|
let entries = vec![Ok(Findings {
|
||||||
file: Path::new("misnamed_file.png").to_path_buf(),
|
file: Path::new("misnamed_file.png").to_path_buf(),
|
||||||
|
@ -466,8 +469,9 @@ fn verbosity() {
|
||||||
#[test]
|
#[test]
|
||||||
/// Ensures that smart strings don't deviate from std's Strings
|
/// Ensures that smart strings don't deviate from std's Strings
|
||||||
fn validate_string_type() {
|
fn validate_string_type() {
|
||||||
use fif::String as SmartString;
|
|
||||||
use std::string::String as StdString;
|
use std::string::String as StdString;
|
||||||
|
|
||||||
|
use fif::String as SmartString;
|
||||||
assert_eq!(SmartString::new(), StdString::new());
|
assert_eq!(SmartString::new(), StdString::new());
|
||||||
assert_eq!(SmartString::from("smol"), StdString::from("smol"));
|
assert_eq!(SmartString::from("smol"), StdString::from("smol"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
Loading…
Reference in a new issue