use interruptible::InterruptibilityState;
use own::{OwnedOrMutRef, OwnedOrRef};
use peace_profile_model::Profile;
use peace_resource_rt::paths::{
PeaceAppDir, PeaceDir, ProfileDir, ProfileHistoryDir, WorkspaceDir,
};
use peace_rt_model::Workspace;
use peace_rt_model_core::params::{ProfileParams, WorkspaceParams};
use type_reg::untagged::{BoxDt, TypeReg};
use crate::{CmdCtxSpnfParams, CmdCtxSpnfParamsBuilder, CmdCtxTypes};
#[derive(Debug)]
pub struct CmdCtxSpnf<'ctx, CmdCtxTypesT>
where
CmdCtxTypesT: CmdCtxTypes,
{
pub output: OwnedOrMutRef<'ctx, CmdCtxTypesT::Output>,
pub fields: CmdCtxSpnfFields<'ctx, CmdCtxTypesT>,
}
#[derive(Debug)]
pub struct CmdCtxSpnfFields<'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 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>,
}
impl<'ctx, CmdCtxTypesT> CmdCtxSpnf<'ctx, CmdCtxTypesT>
where
CmdCtxTypesT: CmdCtxTypes,
{
pub fn builder<'ctx_local>() -> CmdCtxSpnfParamsBuilder<'ctx_local, CmdCtxTypesT> {
CmdCtxSpnfParams::<'ctx_local, CmdCtxTypesT>::builder()
}
pub fn output(&self) -> &CmdCtxTypesT::Output {
&self.output
}
pub fn output_mut(&mut self) -> &mut CmdCtxTypesT::Output {
&mut self.output
}
pub fn fields(&self) -> &CmdCtxSpnfFields<'_, CmdCtxTypesT> {
&self.fields
}
pub fn fields_mut(&mut self) -> &mut CmdCtxSpnfFields<'ctx, CmdCtxTypesT> {
&mut self.fields
}
}
impl<CmdCtxTypesT> CmdCtxSpnfFields<'_, 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 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
}
}