//! Thumbnail generation job descriptor.

use shared::MaterialDesc;

#[derive(Debug, Clone)]
pub struct ThumbnailJob {
    pub cache_key: String,
    pub source: ThumbnailJobSource,
}

#[derive(Debug, Clone)]
pub enum ThumbnailJobSource {
    Model {
        model_path: String,
    },
    MeshSubAsset {
        model_path: String,
        mesh_label: String,
        material_label: Option<String>,
    },
    SourceMaterial {
        model_path: String,
        material_label: String,
    },
    MaterialAsset {
        label: String,
        material: Box<MaterialDesc>,
    },
}

impl ThumbnailJobSource {
    pub fn label(&self) -> &str {
        match self {
            Self::Model { model_path }
            | Self::MeshSubAsset { model_path, .. }
            | Self::SourceMaterial { model_path, .. } => model_path,
            Self::MaterialAsset { label, .. } => label,
        }
    }
}
