hgame 0.26.4

CG production management structs, e.g. of assets, personnels, progress, etc.
Documentation
use super::*;
use chrono::prelude::{DateTime, Utc};
use glob::Paths;
use hconf::{BriefFormat, SnapshotPurpose, TurntableSource};
use mkutil::FileCopySpec;

/// Interface to what Hunter considers central storages of a project,
/// usually a folder on a network server.
pub trait ProductionStorage: fmt::Debug {
    /// Path to "central storage" of the given project.
    fn project_root(&self, project: &Project, workspace: &Workspace) -> AnyResult<PathBuf>;

    /// Path to "render image central" of the given project. Always uses [`Workspace::Server`].
    fn render_image_root(&self, project: &Project) -> AnyResult<PathBuf>;
}

/// Interface to how Hunter can locate source arts of an asset.
pub trait SourceArts: DynClone + fmt::Debug {
    /// Gets root directory of a [`ProductionAsset`],
    /// with [`Workspace::Server`], a path on a shared network drive,
    /// and [`Workspace::Local`], a path on the user's local drive.
    fn asset_root_dir(
        &self,
        project: &Project,
        asset: &ProductionAsset,
        workspace: &Workspace,
    ) -> AnyResult<PathBuf>;

    /// Gets root directory of a [`AssetLod`] of a [`ProductionAsset`],
    /// with [`Workspace::Server`], a path on a shared network drive,
    /// and [`Workspace::Local`], a path on the user's local drive.
    fn asset_lod_root_dir(
        &self,
        project: &Project,
        asset: &ProductionAsset,
        lod: &AssetLod,
        workspace: &Workspace,
    ) -> AnyResult<PathBuf>;

    /// Generates template (i.e. mostly empty) files for the [`ProductionAsset`]. Always uses [`Workspace::Server`].
    fn make_templates(
        &self,
        project: &Project,
        asset: &ProductionAsset,
        lod: &AssetLod,
    ) -> AnyResult<Vec<FileCopySpec>>;

    /// Removes all data of the [`ProductionAsset`] on disk.
    fn delete_asset_dir(
        &self,
        project: &Project,
        asset: &ProductionAsset,
        workspace: &Workspace,
    ) -> AnyResult<()>;

    /// Gets path to Maya model file of the [`ProductionAsset`].
    fn maya_model(
        &self,
        project: &Project,
        asset: &ProductionAsset,
        lod: &AssetLod,
        workspace: &Workspace,
    ) -> AnyResult<PathBuf>;

    /// Gets path to Maya rig file of the [`ProductionAsset`].
    fn maya_rig(
        &self,
        project: &Project,
        asset: &ProductionAsset,
        lod: &AssetLod,
        workspace: &Workspace,
    ) -> AnyResult<PathBuf>;
}

dyn_clone::clone_trait_object!(SourceArts);

// ----------------------------------------------------------------------------
/// Interface to where Hunter looks for brief files and folders.
pub trait BriefDocImg: DynClone + fmt::Debug {
    /// Asset-specific path to its briefs.
    fn asset_brief_main_dir(
        &self,
        project: &Project,
        asset: &ProductionAsset,
    ) -> AnyResult<PathBuf>;

    /// Asset-specific path to its briefs repository which contains reference images for the asset.
    fn asset_brief_repo_dir(
        &self,
        project: &Project,
        asset: &ProductionAsset,
    ) -> AnyResult<PathBuf>;

    /// Asset-specific path to its reference images file.
    fn asset_brief_reference_images(
        &self,
        project: &Project,
        asset: &ProductionAsset,
        format: &BriefFormat,
    ) -> AnyResult<PathBuf>;
}

dyn_clone::clone_trait_object!(BriefDocImg);

// ----------------------------------------------------------------------------
/// Interface to the where Hunter should upload files that are shared across a department to.
pub trait UniversalDefects: DynClone + fmt::Debug {
    /// Path to "universal storage" of defect tracking for a department.
    fn universal_defect_root(&self) -> AnyResult<PathBuf>;

    /// Used to skip the uploading if the given path already is universally accessible.
    fn is_universal_defect_accessible(&self, path: &Path) -> bool;

    /// Asset-specific path to the defect tracking image folder for the given day.
    fn asset_defect_dated_dir(
        &self,
        project: &Project,
        asset: &ProductionAsset,
        date: &DateTime<Utc>,
    ) -> AnyResult<PathBuf>;

    /// Uploads the given file -- usually an image -- to its
    /// asset-specific location and returns path of target file after copying.
    fn make_defect_file_universal(
        &self,
        file: &Path,
        project: &Project,
        asset: &ProductionAsset,
    ) -> AnyResult<PathBuf>;
}

dyn_clone::clone_trait_object!(UniversalDefects);

// ----------------------------------------------------------------------------
pub trait SnapshotReview: DynClone + fmt::Debug + Send + Sync {
    /// Asset-specific paths to the snapshot image sub-folder.
    fn asset_snapshot_subdirs(
        &self,
        project: &Project,
        asset: &ProductionAsset,
        purpose: &SnapshotPurpose,
    ) -> AnyResult<Paths>;

    /// Uploads the given snapshot image to proper folder.
    fn upload_snapshot(
        &self,
        img: &Path,
        project: &Project,
        asset: &ProductionAsset,
        purpose: &SnapshotPurpose,
    ) -> AnyResult<PathBuf>;
}

dyn_clone::clone_trait_object!(SnapshotReview);

// ----------------------------------------------------------------------------
pub trait TurntableReview: DynClone + fmt::Debug + Send + Sync {
    fn asset_turntable_subdirs(
        &self,
        project: &Project,
        asset: &ProductionAsset,
        source: &TurntableSource,
        lod: &AssetLod,
    ) -> AnyResult<Paths>;

    fn img_extension(&self, source: &TurntableSource) -> PathBuf;
}

dyn_clone::clone_trait_object!(TurntableReview);