peace_item_sh_cmd/
sh_cmd_data.rs

1use std::marker::PhantomData;
2
3use peace::{
4    cfg::{accessors::Stored, State},
5    data::Data,
6};
7
8use crate::{ShCmdExecutionRecord, ShCmdStateLogical};
9
10/// Data used to run a shell command.
11///
12/// # Type Parameters
13///
14/// * `Id`: A zero-sized type used to distinguish different command execution
15///   parameters from each other.
16#[derive(Data, Debug)]
17pub struct ShCmdData<'exec, Id>
18where
19    Id: Send + Sync + 'static,
20{
21    /// Stored states of this item's previous execution.
22    state_current_stored: Stored<'exec, State<ShCmdStateLogical<Id>, ShCmdExecutionRecord>>,
23
24    /// Marker.
25    marker: PhantomData<Id>,
26}
27
28impl<Id> ShCmdData<'_, Id>
29where
30    Id: Send + Sync + 'static,
31{
32    /// Returns the previous states.
33    pub fn state_current_stored(
34        &self,
35    ) -> Option<&State<ShCmdStateLogical<Id>, ShCmdExecutionRecord>> {
36        self.state_current_stored.get()
37    }
38}