use std::io::Write;
pub trait DeviceRenderer {
type DeviceInfo;
fn render<W: Write>(
&self,
writer: &mut W,
info: &Self::DeviceInfo,
width: u16,
height: u16,
is_remote: bool,
) -> std::io::Result<()>;
fn render_summary<W: Write>(
&self,
writer: &mut W,
info: &Self::DeviceInfo,
width: u16,
) -> std::io::Result<()>;
fn min_width(&self) -> u16 {
80
}
fn min_height(&self) -> u16 {
24
}
}
pub trait MultiDeviceRenderer: DeviceRenderer {
fn render_multiple<W: Write>(
&self,
writer: &mut W,
devices: &[Self::DeviceInfo],
width: u16,
height: u16,
scroll_offset: usize,
) -> std::io::Result<()>;
fn calculate_visible_count(&self, width: u16, height: u16) -> usize;
}
pub trait GpuRenderer<T>: DeviceRenderer<DeviceInfo = T> {
fn render_utilization_graph<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
) -> std::io::Result<()>;
fn render_memory_usage<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
) -> std::io::Result<()>;
fn render_temperature<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
) -> std::io::Result<()>;
fn render_processes<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
height: u16,
) -> std::io::Result<()>;
}
pub trait CpuRenderer<T>: DeviceRenderer<DeviceInfo = T> {
fn render_core_visualization<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
) -> std::io::Result<()>;
fn render_frequency<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
) -> std::io::Result<()>;
fn render_temperature<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
) -> std::io::Result<()>;
}
pub trait MemoryRenderer<T>: DeviceRenderer<DeviceInfo = T> {
fn render_usage_bars<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
) -> std::io::Result<()>;
fn render_stats_table<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
) -> std::io::Result<()>;
}
pub trait StorageRenderer<T>: DeviceRenderer<DeviceInfo = T> {
fn render_usage_bars<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
) -> std::io::Result<()>;
fn render_io_stats<W: Write>(
&self,
writer: &mut W,
info: &T,
width: u16,
) -> std::io::Result<()>;
}