Improve code clarity, write Alert::load()
This commit is contained in:
parent
16e3f73616
commit
bc9080fe2f
16
src/lib.rs
16
src/lib.rs
|
@ -15,8 +15,8 @@ pub mod pomodoro {
|
||||||
device: &'a Device,
|
device: &'a Device,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Alert<'_> {
|
impl<'a> Alert<'a> {
|
||||||
pub fn new<'a, P: AsRef<Path>>(path: &'a P, device: &'a Device) -> Alert<'a> {
|
pub fn new<P: AsRef<Path>>(path: &'a P, device: &'a Device) -> Alert<'a> {
|
||||||
Alert {
|
Alert {
|
||||||
path: path.as_ref(),
|
path: path.as_ref(),
|
||||||
device,
|
device,
|
||||||
|
@ -30,8 +30,12 @@ pub mod pomodoro {
|
||||||
rodio::play_raw(self.device, source.convert_samples());
|
rodio::play_raw(self.device, source.convert_samples());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
pub fn load<P: AsRef<Path>>(mut self, new_path: &'a P) -> Self {
|
||||||
|
self.path = new_path.as_ref();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum State {
|
pub enum State {
|
||||||
Work,
|
Work,
|
||||||
|
@ -75,13 +79,13 @@ pub mod pomodoro {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_data_directory<P: AsRef<Path>>(mut self, path: &P) -> Config {
|
pub fn with_data_directory<P: AsRef<Path>>(mut self, path: &P) -> Config {
|
||||||
self.data_directory = path.as_ref().to_owned();
|
self.data_directory = path.as_ref().to_path_buf();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_data_directory() -> PathBuf {
|
fn get_data_directory() -> PathBuf {
|
||||||
let dirs = ProjectDirs::from("moe", "paoda", "domasi").unwrap();
|
let dirs = ProjectDirs::from("moe", "paoda", "Domasi").unwrap();
|
||||||
dirs.data_dir().to_owned()
|
dirs.data_dir().to_path_buf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue