Skip to main content

wowlab_engine_application/
resolved_handler.rs

1use wowlab_engine_ports::SpecHandler;
2
3/// Owned spec handler built from resolved application inputs.
4pub struct ResolvedHandler {
5    inner: Box<dyn SpecHandler>,
6}
7
8impl ResolvedHandler {
9    /// Wraps a concrete resolved handler for chunk execution.
10    pub fn new(handler: impl SpecHandler + 'static) -> Self {
11        Self {
12            inner: Box::new(handler),
13        }
14    }
15
16    pub(crate) fn from_boxed(inner: Box<dyn SpecHandler>) -> Self {
17        Self { inner }
18    }
19
20    /// Returns the handler's full character-sheet report.
21    #[must_use]
22    pub fn paperdoll(&self) -> Option<wowlab_engine_ports::Paperdoll> {
23        self.inner.paperdoll()
24    }
25
26    pub(crate) fn into_inner(self) -> Box<dyn SpecHandler> {
27        self.inner
28    }
29
30    pub(crate) fn handler_mut(&mut self) -> &mut dyn SpecHandler {
31        self.inner.as_mut()
32    }
33}
34
35impl std::fmt::Debug for ResolvedHandler {
36    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37        f.debug_struct("ResolvedHandler").finish_non_exhaustive()
38    }
39}
40
41impl From<Box<dyn SpecHandler>> for ResolvedHandler {
42    fn from(handler: Box<dyn SpecHandler>) -> Self {
43        Self::from_boxed(handler)
44    }
45}