Skip to content

Commit

Permalink
feat: prototype for timer
Browse files Browse the repository at this point in the history
  • Loading branch information
iahmadgad committed Oct 28, 2024
1 parent f832db0 commit 567837a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod alarm;
pub mod timer;
41 changes: 41 additions & 0 deletions src/timer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#[derive(Debug, PartialEq)]
pub struct Timer {
length: u32,
message: Option<String>,
vibrate: bool,
}

impl Timer {
pub fn new() -> Timer {
Timer {
length: 0,
message: None,
vibrate: false,
}
}

pub fn hour(mut self, hour: u32) -> Self {
self.length += hour * 3600;
self
}

pub fn minutes(mut self, minutes: u32) -> Self {
self.length += minutes * 60;
self
}

pub fn seconds(mut self, seconds: u32) -> Self {
self.length += seconds;
self
}

pub fn message(mut self, message: String) -> Self {
self.message = Some(message);
self
}

pub fn vibrate(mut self, vibrate: bool) -> Self {
self.vibrate = vibrate;
self
}
}

0 comments on commit 567837a

Please sign in to comment.