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 42
use peace::{
    data::{
        accessors::{RMaybe, R},
        Data,
    },
    resources::states::StatesSaved,
};
use crate::ShSyncCmdParams;
/// Data used to run a shell command.
///
/// # Type Parameters
///
/// * `Id`: A zero-sized type used to distinguish different command execution
///   parameters from each other.
#[derive(Data, Debug)]
pub struct ShSyncCmdData<'op, Id>
where
    Id: Send + Sync + 'static,
{
    /// Parameters to determine what shell command to run.
    sh_sync_cmd_params: R<'op, ShSyncCmdParams<Id>>,
    /// Saved states with this item spec's previous execution.
    states_saved: RMaybe<'op, StatesSaved>,
}
impl<'op, Id> ShSyncCmdData<'op, Id>
where
    Id: Send + Sync + 'static,
{
    /// Returns the parameters to determine what shell command to run.
    pub fn sh_sync_cmd_params(&self) -> &ShSyncCmdParams<Id> {
        &self.sh_sync_cmd_params
    }
    /// Returns the previous states.
    pub fn states_saved(&self) -> Option<&StatesSaved> {
        self.states_saved.as_deref()
    }
}