0.1.0-0-pre.3
This commit is contained in:
36
crates/engines/engine-v1-common/src/frame.rs
Normal file
36
crates/engines/engine-v1-common/src/frame.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
// file: crates/engines/engine-v1-common/src/frame.rs
|
||||
// version: 1
|
||||
|
||||
/// Immutable timing information associated with one engine update.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct EngineFrame {
|
||||
index: u64,
|
||||
delta: std::time::Duration,
|
||||
elapsed: std::time::Duration,
|
||||
}
|
||||
|
||||
impl EngineFrame {
|
||||
/// Creates timing information for one update.
|
||||
#[must_use]
|
||||
pub const fn new(index: u64, delta: std::time::Duration, elapsed: std::time::Duration) -> Self {
|
||||
return Self { index, delta, elapsed };
|
||||
}
|
||||
|
||||
/// Returns the zero-based update index.
|
||||
#[must_use]
|
||||
pub const fn index(self) -> u64 {
|
||||
return self.index;
|
||||
}
|
||||
|
||||
/// Returns the duration represented by this update.
|
||||
#[must_use]
|
||||
pub const fn delta(self) -> std::time::Duration {
|
||||
return self.delta;
|
||||
}
|
||||
|
||||
/// Returns the accumulated simulated duration before this update completes.
|
||||
#[must_use]
|
||||
pub const fn elapsed(self) -> std::time::Duration {
|
||||
return self.elapsed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user