use async_trait::async_trait;
use bytesize::ByteSize;
use concerto_core::GpuId;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GpuSnapshot {
pub id: GpuId,
pub memory_total: ByteSize,
pub memory_used: ByteSize,
pub temperature_celsius: u32,
pub utilisation_percent: u32,
pub ecc_errors_uncorrected: u64,
}
#[async_trait]
pub trait GpuMonitor: Send + Sync {
fn gpu_count(&self) -> usize;
async fn snapshot(&self) -> Vec<GpuSnapshot>;
}
#[derive(Debug, thiserror::Error)]
pub enum GpuMonitorError {
#[error("failed to initialise NVML: {0}")]
NvmlInit(String),
#[error("NVML query failed: {0}")]
NvmlQuery(String),
#[error("GPU index {0} is out of range")]
GpuOutOfRange(usize),
#[error("feature not supported on this platform: {0}")]
Unsupported(&'static str),
}