1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::ops::{Deref, DerefMut};

use peace_cfg::ItemId;
use peace_resources::type_reg::untagged::{BoxDtDisplay, TypeReg};

/// Type registry for each item's `State`.
///
/// This is used to deserialize [`StatesCurrentFile`] and [`StatesGoalFile`].
///
/// Note: [`ItemParamsTypeReg`] uses [`BoxDt`], whereas this uses
/// [`BoxDtDisplay`].
///
/// [`BoxDt`]: peace_resources::type_reg::untagged::BoxDt
/// [`BoxDtDisplay`]: peace_resources::type_reg::untagged::BoxDtDisplay
/// [`ItemParamsTypeReg`]: crate::ItemParamsTypeReg
/// [`Params`]: peace_cfg::Item::Params
/// [`StatesGoalFile`]: peace_resources::paths::StatesGoalFile
/// [`StatesCurrentFile`]: peace_resources::paths::StatesCurrentFile
#[derive(Debug, Default)]
pub struct StatesTypeReg(TypeReg<ItemId, BoxDtDisplay>);

impl StatesTypeReg {
    /// Returns new `StatesTypeReg`.
    pub fn new() -> Self {
        Self::default()
    }
}

impl Deref for StatesTypeReg {
    type Target = TypeReg<ItemId, BoxDtDisplay>;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for StatesTypeReg {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}