use interruptible::InterruptibilityState;
use own::{OwnedOrMutRef, OwnedOrRef};
use peace_flow_rt::Flow;
use peace_params::ParamsSpecs;
use peace_profile_model::Profile;
use peace_resource_rt::{
paths::{FlowDir, PeaceAppDir, PeaceDir, ProfileDir, ProfileHistoryDir, WorkspaceDir},
resources::ts::SetUp,
Resources,
};
use peace_rt_model::{ParamsSpecsTypeReg, StatesTypeReg, Workspace};
use peace_rt_model_core::params::{FlowParams, ProfileParams, WorkspaceParams};
use type_reg::untagged::{BoxDt, TypeReg};
use crate::{CmdCtxSpsfParams, CmdCtxSpsfParamsBuilder, CmdCtxTypes};
#[derive(Debug)]
pub struct CmdCtxSpsf<'ctx, CmdCtxTypesT>
where
CmdCtxTypesT: CmdCtxTypes,
{
pub output: OwnedOrMutRef<'ctx, CmdCtxTypesT::Output>,
#[cfg(feature = "output_progress")]
pub cmd_progress_tracker: peace_rt_model::CmdProgressTracker,
pub fields: CmdCtxSpsfFields<'ctx, CmdCtxTypesT>,
}
#[derive(Debug)]
pub struct CmdCtxSpsfFields<'ctx, CmdCtxTypesT>
where
CmdCtxTypesT: CmdCtxTypes,
{
pub interruptibility_state: InterruptibilityState<'static, 'static>,
pub workspace: OwnedOrRef<'ctx, Workspace>,
pub profile: Profile,
pub profile_dir: ProfileDir,
pub profile_history_dir: ProfileHistoryDir,
pub flow: OwnedOrRef<'ctx, Flow<CmdCtxTypesT::AppError>>,
pub flow_dir: FlowDir,
pub workspace_params_type_reg: TypeReg<CmdCtxTypesT::WorkspaceParamsKey, BoxDt>,
pub workspace_params: WorkspaceParams<CmdCtxTypesT::WorkspaceParamsKey>,
pub profile_params_type_reg: TypeReg<CmdCtxTypesT::ProfileParamsKey, BoxDt>,
pub profile_params: ProfileParams<CmdCtxTypesT::ProfileParamsKey>,
pub flow_params_type_reg: TypeReg<CmdCtxTypesT::FlowParamsKey, BoxDt>,
pub flow_params: FlowParams<CmdCtxTypesT::FlowParamsKey>,
pub params_specs_type_reg: ParamsSpecsTypeReg,
pub params_specs: ParamsSpecs,
pub states_type_reg: StatesTypeReg,
pub resources: Resources<SetUp>,
}
impl<'ctx, CmdCtxTypesT> CmdCtxSpsf<'ctx, CmdCtxTypesT>
where
CmdCtxTypesT: CmdCtxTypes,
{
pub fn builder<'ctx_local>() -> CmdCtxSpsfParamsBuilder<'ctx_local, CmdCtxTypesT> {
CmdCtxSpsfParams::<'ctx_local, CmdCtxTypesT>::builder()
}
pub fn output(&self) -> &CmdCtxTypesT::Output {
&self.output
}
pub fn output_mut(&mut self) -> &mut CmdCtxTypesT::Output {
&mut self.output
}
#[cfg(feature = "output_progress")]
pub fn cmd_progress_tracker(&self) -> &peace_rt_model::CmdProgressTracker {
&self.cmd_progress_tracker
}
#[cfg(feature = "output_progress")]
pub fn cmd_progress_tracker_mut(&mut self) -> &mut peace_rt_model::CmdProgressTracker {
&mut self.cmd_progress_tracker
}
pub fn fields(&self) -> &CmdCtxSpsfFields<'_, CmdCtxTypesT> {
&self.fields
}
pub fn fields_mut(&mut self) -> &mut CmdCtxSpsfFields<'ctx, CmdCtxTypesT> {
&mut self.fields
}
}
impl<CmdCtxTypesT> CmdCtxSpsfFields<'_, CmdCtxTypesT>
where
CmdCtxTypesT: CmdCtxTypes,
{
pub fn interruptibility_state(&mut self) -> InterruptibilityState<'_, '_> {
self.interruptibility_state.reborrow()
}
pub fn workspace(&self) -> &Workspace {
&self.workspace
}
pub fn workspace_dir(&self) -> &WorkspaceDir {
self.workspace.dirs().workspace_dir()
}
pub fn peace_dir(&self) -> &PeaceDir {
self.workspace.dirs().peace_dir()
}
pub fn peace_app_dir(&self) -> &PeaceAppDir {
self.workspace.dirs().peace_app_dir()
}
pub fn profile(&self) -> &Profile {
&self.profile
}
pub fn profile_dir(&self) -> &ProfileDir {
&self.profile_dir
}
pub fn profile_history_dir(&self) -> &ProfileHistoryDir {
&self.profile_history_dir
}
pub fn flow(&self) -> &Flow<CmdCtxTypesT::AppError> {
&self.flow
}
pub fn flow_dir(&self) -> &FlowDir {
&self.flow_dir
}
pub fn workspace_params_type_reg(&self) -> &TypeReg<CmdCtxTypesT::WorkspaceParamsKey, BoxDt> {
&self.workspace_params_type_reg
}
pub fn workspace_params_type_reg_mut(
&mut self,
) -> &mut TypeReg<CmdCtxTypesT::WorkspaceParamsKey, BoxDt> {
&mut self.workspace_params_type_reg
}
pub fn workspace_params(&self) -> &WorkspaceParams<CmdCtxTypesT::WorkspaceParamsKey> {
&self.workspace_params
}
pub fn workspace_params_mut(
&mut self,
) -> &mut WorkspaceParams<CmdCtxTypesT::WorkspaceParamsKey> {
&mut self.workspace_params
}
pub fn profile_params_type_reg(&self) -> &TypeReg<CmdCtxTypesT::ProfileParamsKey, BoxDt> {
&self.profile_params_type_reg
}
pub fn profile_params_type_reg_mut(
&mut self,
) -> &mut TypeReg<CmdCtxTypesT::ProfileParamsKey, BoxDt> {
&mut self.profile_params_type_reg
}
pub fn profile_params(&self) -> &ProfileParams<CmdCtxTypesT::ProfileParamsKey> {
&self.profile_params
}
pub fn profile_params_mut(&mut self) -> &mut ProfileParams<CmdCtxTypesT::ProfileParamsKey> {
&mut self.profile_params
}
pub fn flow_params_type_reg(&self) -> &TypeReg<CmdCtxTypesT::FlowParamsKey, BoxDt> {
&self.flow_params_type_reg
}
pub fn flow_params_type_reg_mut(&mut self) -> &mut TypeReg<CmdCtxTypesT::FlowParamsKey, BoxDt> {
&mut self.flow_params_type_reg
}
pub fn flow_params(&self) -> &FlowParams<CmdCtxTypesT::FlowParamsKey> {
&self.flow_params
}
pub fn flow_params_mut(&mut self) -> &mut FlowParams<CmdCtxTypesT::FlowParamsKey> {
&mut self.flow_params
}
pub fn params_specs_type_reg(&self) -> &ParamsSpecsTypeReg {
&self.params_specs_type_reg
}
pub fn params_specs(&self) -> &ParamsSpecs {
&self.params_specs
}
pub fn states_type_reg(&self) -> &StatesTypeReg {
&self.states_type_reg
}
pub fn resources(&self) -> &Resources<SetUp> {
&self.resources
}
pub fn resources_mut(&mut self) -> &mut Resources<SetUp> {
&mut self.resources
}
}