pub struct Timer {
pub config: TimerConfig,
pub state: TimerState,
pub cycle: TimerCycle,
pub cycles_count: TimerLoop,
pub started_at: Option<Instant>,
pub elapsed: usize,
}
Expand description
The main timer struct.
Fields§
§config: TimerConfig
The current timer configuration.
state: TimerState
The current timer state.
cycle: TimerCycle
The current timer cycle.
cycles_count: TimerLoop
The current cycles counter.
started_at: Option<Instant>
Available on crate feature
§server
only.elapsed: usize
Available on crate feature
server
only.Implementations§
Source§impl Timer
impl Timer
pub fn elapsed(&self) -> usize
Available on crate feature
server
only.pub async fn update(&mut self)
Available on crate feature
server
only.pub async fn fire_event(&self, event: TimerEvent)
Available on crate feature
server
only.pub async fn fire_events(&self, events: impl IntoIterator<Item = TimerEvent>)
Available on crate feature
server
only.pub async fn start(&mut self) -> Result<()>
Available on crate feature
server
only.pub async fn set(&mut self, duration: usize) -> Result<()>
Available on crate feature
server
only.pub async fn pause(&mut self) -> Result<()>
Available on crate feature
server
only.pub async fn resume(&mut self) -> Result<()>
Available on crate feature
server
only.pub async fn stop(&mut self) -> Result<()>
Available on crate feature
server
only.Trait Implementations§
Source§impl<'de> Deserialize<'de> for Timer
impl<'de> Deserialize<'de> for Timer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Timer
Auto Trait Implementations§
impl Freeze for Timer
impl !RefUnwindSafe for Timer
impl Send for Timer
impl Sync for Timer
impl Unpin for Timer
impl !UnwindSafe for Timer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more