Timer constructors & traits
This commit is contained in:
parent
e55be91d24
commit
270663e529
@ -176,11 +176,18 @@ impl std::fmt::Display for Error{
|
|||||||
impl std::error::Error for Error{}
|
impl std::error::Error for Error{}
|
||||||
|
|
||||||
//wrapper type which holds type state internally
|
//wrapper type which holds type state internally
|
||||||
|
#[derive(Clone,Debug)]
|
||||||
pub enum Timer<T:TimerState>{
|
pub enum Timer<T:TimerState>{
|
||||||
Paused(TimerFixed<T,Paused>),
|
Paused(TimerFixed<T,Paused>),
|
||||||
Unpaused(TimerFixed<T,Unpaused>),
|
Unpaused(TimerFixed<T,Unpaused>),
|
||||||
}
|
}
|
||||||
impl<T:TimerState> Timer<T>{
|
impl<T:TimerState> Timer<T>{
|
||||||
|
pub fn paused(time:Time,new_time:Time)->Self{
|
||||||
|
Self::Paused(TimerFixed::new(time,new_time))
|
||||||
|
}
|
||||||
|
pub fn unpaused(time:Time,new_time:Time)->Self{
|
||||||
|
Self::Unpaused(TimerFixed::new(time,new_time))
|
||||||
|
}
|
||||||
pub fn time(&self,time:Time)->Time{
|
pub fn time(&self,time:Time)->Time{
|
||||||
match self{
|
match self{
|
||||||
Self::Paused(timer)=>timer.time(time),
|
Self::Paused(timer)=>timer.time(time),
|
||||||
|
Loading…
Reference in New Issue
Block a user