diff --git a/rustfmt.toml b/rustfmt.toml index 74c8af6..6733e04 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1,2 @@ -imports_granularity = "Item" \ No newline at end of file +imports_granularity = "Item" +group_imports = "StdExternalCrate" \ No newline at end of file diff --git a/src/args.rs b/src/args.rs index fbc7a64..cf391b1 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,6 +1,7 @@ -use clap::Clap; use std::path::PathBuf; +use clap::Clap; + #[derive(Clap, Debug)] pub struct Opts { pub output_dir: Option, diff --git a/src/audio_excerpt.rs b/src/audio_excerpt.rs index 3dbe10a..239f548 100644 --- a/src/audio_excerpt.rs +++ b/src/audio_excerpt.rs @@ -1,9 +1,11 @@ +use std::i16; + +use hound::WavSpec; +use rodio::Source; + use crate::audio_time::AudioTime; use crate::config::NUM_PLOT_DATA_POINTS; use crate::config::NUM_SAMPLES_PER_AVERAGE_VOLUME; -use hound::WavSpec; -use rodio::Source; -use std::i16; #[derive(Clone)] pub struct AudioExcerpt { diff --git a/src/audio_time.rs b/src/audio_time.rs index 0c41e91..f7b0e44 100644 --- a/src/audio_time.rs +++ b/src/audio_time.rs @@ -1,6 +1,7 @@ -use hound::WavSpec; use std::ops; +use hound::WavSpec; + #[derive(Debug, Copy, Clone, PartialEq)] pub struct AudioTime { pub time: f64, diff --git a/src/config_file.rs b/src/config_file.rs index 5d6df03..1f84dae 100644 --- a/src/config_file.rs +++ b/src/config_file.rs @@ -1,11 +1,12 @@ +use std::fs; +use std::path::Path; +use std::path::PathBuf; + use anyhow::anyhow; use anyhow::Context; use anyhow::Result; use serde::Deserialize; use serde::Serialize; -use std::fs; -use std::path::Path; -use std::path::PathBuf; use crate::config; diff --git a/src/cut.rs b/src/cut.rs index 69c2ccb..92a7301 100644 --- a/src/cut.rs +++ b/src/cut.rs @@ -1,10 +1,11 @@ -use anyhow::Context; -use anyhow::Result; use std::fs::create_dir_all; use std::path::Path; use std::path::PathBuf; use std::process::Command; +use anyhow::Context; +use anyhow::Result; + use crate::audio_excerpt::AudioExcerpt; use crate::audio_time::AudioTime; use crate::config::MAX_OFFSET; diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 6e4f78b..d535d67 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -6,15 +6,6 @@ mod session_manager; use std::path::Path; -use crate::cut::CutInfo; -use crate::excerpt_collection::ExcerptCollection; -use crate::gui::session_manager::SessionIdentifier; -use crate::gui::session_manager::SessionManager; -use crate::recording::recording_thread_handle_status::RecordingThreadHandleStatus; -use crate::run_args::RunArgs; -use crate::service_config::ServiceConfig; -use crate::song::Song; - use eframe::egui::Button; use eframe::egui::Color32; use eframe::egui::Label; @@ -30,6 +21,14 @@ use self::cutting_thread::CuttingThreadHandle; use self::playback::play_excerpt; use self::playback::PlaybackThreadHandle; use self::plot::ExcerptPlot; +use crate::cut::CutInfo; +use crate::excerpt_collection::ExcerptCollection; +use crate::gui::session_manager::SessionIdentifier; +use crate::gui::session_manager::SessionManager; +use crate::recording::recording_thread_handle_status::RecordingThreadHandleStatus; +use crate::run_args::RunArgs; +use crate::service_config::ServiceConfig; +use crate::song::Song; #[derive(PartialEq, Eq, Copy, Clone)] struct SongIdentifier { diff --git a/src/gui/plot.rs b/src/gui/plot.rs index 94aee1e..eb8a5f0 100644 --- a/src/gui/plot.rs +++ b/src/gui/plot.rs @@ -1,12 +1,11 @@ use eframe::egui::plot::*; use eframe::egui::*; +use super::config; use crate::audio_time::AudioTime; use crate::excerpt_collection::NamedExcerpt; use crate::song::Song; -use super::config; - pub struct ExcerptPlot { pub excerpt: NamedExcerpt, pub cut_time: AudioTime, diff --git a/src/main.rs b/src/main.rs index c94551e..2ffe4e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,13 +17,14 @@ pub mod wav; use std::path::Path; -use crate::gui::StriputaryGui; use anyhow::Result; use args::Opts; use clap::Clap; use config_file::ConfigFile; use service_config::ServiceConfig; +use crate::gui::StriputaryGui; + fn main() -> Result<(), anyhow::Error> { let args = Opts::parse(); let config_file = ConfigFile::read(); diff --git a/src/recording/dbus.rs b/src/recording/dbus.rs index e9659da..3678209 100644 --- a/src/recording/dbus.rs +++ b/src/recording/dbus.rs @@ -1,16 +1,18 @@ -use crate::recording::recording_status::RecordingExitStatus; -use crate::recording::recording_status::RecordingStatus; -use crate::recording_session::RecordingSession; -use crate::service_config::ServiceConfig; -use crate::song::Song; +use std::collections::HashMap; +use std::process::Command; + use anyhow::Context; use anyhow::Result; use dbus::arg::RefArg; use dbus::ffidisp::stdintf::org_freedesktop_dbus::PropertiesPropertiesChanged as PC; use dbus::ffidisp::Connection; use dbus::message::SignalArgs; -use std::collections::HashMap; -use std::process::Command; + +use crate::recording::recording_status::RecordingExitStatus; +use crate::recording::recording_status::RecordingStatus; +use crate::recording_session::RecordingSession; +use crate::service_config::ServiceConfig; +use crate::song::Song; /// Collect dbus information on the songs. /// We could collect the dbus timestamps but they are basically useless diff --git a/src/recording/recorder.rs b/src/recording/recorder.rs index 106c2bb..7ccacd0 100644 --- a/src/recording/recorder.rs +++ b/src/recording/recorder.rs @@ -1,10 +1,11 @@ +use std::path::Path; +use std::process::Command; + use anyhow::anyhow; use anyhow::Context; use anyhow::Result; use regex::Captures; use regex::Regex; -use std::path::Path; -use std::process::Command; use subprocess::Exec; use subprocess::Popen; diff --git a/src/recording/recording_thread.rs b/src/recording/recording_thread.rs index ea08188..30c849a 100644 --- a/src/recording/recording_thread.rs +++ b/src/recording/recording_thread.rs @@ -1,21 +1,5 @@ -use crate::config::TIME_AFTER_SESSION_END; -use crate::config::TIME_BEFORE_SESSION_START; -use crate::config::WAIT_TIME_BEFORE_FIRST_SONG; -use crate::recording::recording_status::RecordingStatus; use std::fs::create_dir_all; use std::path::Path; - -use super::dbus::collect_dbus_info; -use super::dbus::previous_song; -use super::dbus::start_playback; -use super::dbus::stop_playback; -use crate::recording::recorder; -use crate::recording_session::RecordingSession; -use crate::run_args::RunArgs; -use crate::song::Song; -use anyhow::anyhow; -use anyhow::Context; -use anyhow::Result; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; use std::sync::mpsc::Sender; @@ -24,7 +8,23 @@ use std::thread::{self}; use std::time::Duration; use std::time::Instant; +use anyhow::anyhow; +use anyhow::Context; +use anyhow::Result; + +use super::dbus::collect_dbus_info; +use super::dbus::previous_song; +use super::dbus::start_playback; +use super::dbus::stop_playback; use super::recording_status::RecordingExitStatus; +use crate::config::TIME_AFTER_SESSION_END; +use crate::config::TIME_BEFORE_SESSION_START; +use crate::config::WAIT_TIME_BEFORE_FIRST_SONG; +use crate::recording::recorder; +use crate::recording::recording_status::RecordingStatus; +use crate::recording_session::RecordingSession; +use crate::run_args::RunArgs; +use crate::song::Song; pub struct RecordingThread { run_args: RunArgs, diff --git a/src/recording/recording_thread_handle.rs b/src/recording/recording_thread_handle.rs index fc8e06a..8ed3f84 100644 --- a/src/recording/recording_thread_handle.rs +++ b/src/recording/recording_thread_handle.rs @@ -1,4 +1,3 @@ -use anyhow::Result; use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering; use std::sync::mpsc::channel; @@ -6,15 +5,16 @@ use std::sync::Arc; use std::thread::JoinHandle; use std::thread::{self}; +use anyhow::Result; + +use super::recording_status::RecordingExitStatus; +use super::recording_thread::RecordingThread; use crate::config; use crate::data_stream::DataStream; use crate::recording_session::RecordingSession; use crate::run_args::RunArgs; use crate::song::Song; -use super::recording_status::RecordingExitStatus; -use super::recording_thread::RecordingThread; - pub struct RecordingThreadHandle { handle: JoinHandle>, is_running: Arc, diff --git a/src/recording/recording_thread_handle_status.rs b/src/recording/recording_thread_handle_status.rs index 614004c..f6ceff3 100644 --- a/src/recording/recording_thread_handle_status.rs +++ b/src/recording/recording_thread_handle_status.rs @@ -1,8 +1,7 @@ +use super::recording_thread_handle::RecordingThreadHandle; use crate::run_args::RunArgs; use crate::song::Song; -use super::recording_thread_handle::RecordingThreadHandle; - pub enum RecordingThreadHandleStatus { Running(RecordingThreadHandle), Failed(anyhow::Error), diff --git a/src/recording_session.rs b/src/recording_session.rs index 0e17a62..9d7ee61 100644 --- a/src/recording_session.rs +++ b/src/recording_session.rs @@ -1,14 +1,16 @@ -use crate::config; -use crate::song::Song; -use anyhow::Context; -use anyhow::Result; -use serde::Deserialize; -use serde::Serialize; use std::fs; use std::path::Path; use std::path::PathBuf; use std::vec::Vec; +use anyhow::Context; +use anyhow::Result; +use serde::Deserialize; +use serde::Serialize; + +use crate::config; +use crate::song::Song; + #[derive(Serialize, Deserialize, Debug, Clone)] pub struct RecordingSession { #[serde(skip_serializing, skip_deserializing)] diff --git a/src/song.rs b/src/song.rs index d6ffa98..e91f615 100644 --- a/src/song.rs +++ b/src/song.rs @@ -1,9 +1,10 @@ -use serde::Deserialize; -use serde::Serialize; use std::fmt; use std::path::Path; use std::path::PathBuf; +use serde::Deserialize; +use serde::Serialize; + #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] pub struct Song { pub artist: String, diff --git a/src/wav.rs b/src/wav.rs index 9154c38..ffc19f2 100644 --- a/src/wav.rs +++ b/src/wav.rs @@ -1,7 +1,8 @@ +use std::path::Path; + use crate::audio_excerpt::AudioExcerpt; use crate::audio_time::AudioTime; use crate::errors::MissingSongError; -use std::path::Path; pub fn get_volume_average_over_channels(samples: Vec) -> Vec { samples