Timer constructors & traits

This commit is contained in:
Quaternions 2024-07-31 20:59:31 -07:00
parent e55be91d24
commit 270663e529

View File

@ -176,11 +176,18 @@ impl std::fmt::Display for Error{
impl std::error::Error for Error{}
//wrapper type which holds type state internally
#[derive(Clone,Debug)]
pub enum Timer<T:TimerState>{
Paused(TimerFixed<T,Paused>),
Unpaused(TimerFixed<T,Unpaused>),
}
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{
match self{
Self::Paused(timer)=>timer.time(time),