Skip to content

Commit

Permalink
reorder imports too
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehforsch committed Oct 7, 2021
1 parent 014a950 commit 31d2653
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 63 deletions.
3 changes: 2 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
imports_granularity = "Item"
imports_granularity = "Item"
group_imports = "StdExternalCrate"
3 changes: 2 additions & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use clap::Clap;
use std::path::PathBuf;

use clap::Clap;

#[derive(Clap, Debug)]
pub struct Opts {
pub output_dir: Option<PathBuf>,
Expand Down
8 changes: 5 additions & 3 deletions src/audio_excerpt.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/audio_time.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use hound::WavSpec;
use std::ops;

use hound::WavSpec;

#[derive(Debug, Copy, Clone, PartialEq)]
pub struct AudioTime {
pub time: f64,
Expand Down
7 changes: 4 additions & 3 deletions src/config_file.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
5 changes: 3 additions & 2 deletions src/cut.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
17 changes: 8 additions & 9 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions src/gui/plot.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 9 additions & 7 deletions src/recording/dbus.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/recording/recorder.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
32 changes: 16 additions & 16 deletions src/recording/recording_thread.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/recording/recording_thread_handle.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use anyhow::Result;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::sync::mpsc::channel;
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<Result<(RecordingExitStatus, RecordingSession)>>,
is_running: Arc<AtomicBool>,
Expand Down
3 changes: 1 addition & 2 deletions src/recording/recording_thread_handle_status.rs
Original file line number Diff line number Diff line change
@@ -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),
Expand Down
14 changes: 8 additions & 6 deletions src/recording_session.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
5 changes: 3 additions & 2 deletions src/song.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/wav.rs
Original file line number Diff line number Diff line change
@@ -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<i16>) -> Vec<i16> {
samples
Expand Down

0 comments on commit 31d2653

Please sign in to comment.