quantized_density_fields/qdf/
space.rs

1use id::*;
2use qdf::*;
3
4/// Holds information about space region.
5#[derive(Debug, Clone)]
6pub struct Space<S>
7where
8    S: State,
9{
10    id: ID,
11    state: S,
12}
13
14impl<S> Space<S>
15where
16    S: State,
17{
18    #[inline]
19    pub(crate) fn new(id: ID, state: S) -> Self {
20        Self { id, state }
21    }
22
23    /// Gets space id.
24    #[inline]
25    pub fn id(&self) -> ID {
26        self.id
27    }
28
29    /// Gets space state.
30    #[inline]
31    pub fn state(&self) -> &S {
32        &self.state
33    }
34
35    #[inline]
36    pub(crate) fn apply_state(&mut self, state: S) {
37        self.state = state;
38    }
39}
40
41impl<S> Default for Space<S>
42where
43    S: State,
44{
45    #[inline]
46    fn default() -> Self {
47        Self::new(ID::new(), S::default())
48    }
49}