Skip to main content

molpack/context/
state.rs

1//! Runtime state views over [`PackContext`].
2
3use super::PackContext;
4use molrs::types::F;
5
6/// Read-only runtime state view.
7pub struct RuntimeState<'a> {
8    pub(crate) ctx: &'a PackContext,
9}
10
11impl<'a> RuntimeState<'a> {
12    #[inline]
13    pub fn fdist(&self) -> F {
14        self.ctx.fdist
15    }
16
17    #[inline]
18    pub fn frest(&self) -> F {
19        self.ctx.frest
20    }
21
22    #[inline]
23    pub fn ncf(&self) -> usize {
24        self.ctx.ncf()
25    }
26
27    #[inline]
28    pub fn ncg(&self) -> usize {
29        self.ctx.ncg()
30    }
31}
32
33/// Mutable runtime state view.
34pub struct RuntimeStateMut<'a> {
35    pub(crate) ctx: &'a mut PackContext,
36}
37
38impl<'a> RuntimeStateMut<'a> {
39    #[inline]
40    pub fn set_move_flag(&mut self, enabled: bool) {
41        self.ctx.move_flag = enabled;
42    }
43
44    #[inline]
45    pub fn set_init1(&mut self, enabled: bool) {
46        self.ctx.init1 = enabled;
47    }
48}