pub struct SessionConfig { /* private fields */ }Expand description
Validated, reusable settings for a GameSession.
Fields cannot be changed after validation. Use Self::try_new to check
settings from a host or inspector, then GameSession::from_config to
create independent sessions with the same settings.
use ferravex_core::session::{GameSession, SessionConfig, SessionState};
let config = SessionConfig::try_new(64.0, 4, false)?;
assert_eq!(config.hz(), 64.0);
assert_eq!(config.max_steps(), 4);
assert!(!config.autoplay());
let first = GameSession::from_config(config);
let second = GameSession::from_config(config);
assert_eq!(first.state(), SessionState::Ready);
assert_eq!(second.tick(), 0);Implementations§
Source§impl SessionConfig
impl SessionConfig
Sourcepub fn try_new(
hz: f64,
max_steps: u32,
autoplay: bool,
) -> Result<SessionConfig, FixedClockError>
pub fn try_new( hz: f64, max_steps: u32, autoplay: bool, ) -> Result<SessionConfig, FixedClockError>
Validates settings using FixedClock::try_new.
hz must be finite and in 1..=1000, and max_steps must be nonzero.
The tick rate is checked first if both values are invalid. autoplay
selects Playing instead of Ready for each newly created session.
See the SessionConfig example for constructing and reusing settings.
Sourcepub fn hz(&self) -> f64
pub fn hz(&self) -> f64
Returns the validated fixed tick rate in Hz; see SessionConfig.
Sourcepub fn max_steps(&self) -> u32
pub fn max_steps(&self) -> u32
Returns the nonzero per-frame catch-up limit; see SessionConfig.
Sourcepub fn autoplay(&self) -> bool
pub fn autoplay(&self) -> bool
Whether a newly created session starts in Playing; see SessionConfig.
Trait Implementations§
Source§impl Clone for SessionConfig
impl Clone for SessionConfig
Source§fn clone(&self) -> SessionConfig
fn clone(&self) -> SessionConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionConfig
impl Debug for SessionConfig
Source§impl PartialEq for SessionConfig
impl PartialEq for SessionConfig
impl Copy for SessionConfig
impl StructuralPartialEq for SessionConfig
Auto Trait Implementations§
impl Freeze for SessionConfig
impl RefUnwindSafe for SessionConfig
impl Send for SessionConfig
impl Sync for SessionConfig
impl Unpin for SessionConfig
impl UnwindSafe for SessionConfig
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