use serde::Serialize;
use std::error::Error;
use std::fmt;
use std::path::PathBuf;
#[derive(Clone, Debug)]
pub enum ViewerError {
IoError(String),
ParseError(String),
#[allow(dead_code)]
RenderError(String),
}
impl fmt::Display for ViewerError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ViewerError::IoError(msg) => write!(f, "I/O error: {}", msg),
ViewerError::ParseError(msg) => write!(f, "Parse error: {}", msg),
ViewerError::RenderError(msg) => write!(f, "Render error: {}", msg),
}
}
}
impl Error for ViewerError {}
#[allow(dead_code)]
#[derive(Clone, Debug, Serialize)]
pub struct ViewerState {
pub file_type: String,
pub file_path: PathBuf,
pub modified: bool,
pub file_size_bytes: u64,
}
#[allow(dead_code)]
pub trait FileViewer: Send + Sync {
fn render(&self) -> Result<String, ViewerError>;
fn get_state(&self) -> ViewerState;
fn file_type(&self) -> &str;
}