use std::io;
use thiserror::Error;
use super::GraphView;
pub trait GraphRenderer {
fn render(&self, view: &GraphView, sink: &mut dyn io::Write) -> Result<(), GraphRenderError>;
}
#[derive(Debug, Error)]
pub enum GraphRenderError {
#[error("I/O failure while rendering graph")]
Io {
#[source]
source: io::Error,
},
#[error("formatting failure while rendering graph")]
Format {
#[source]
source: std::fmt::Error,
},
}
impl From<io::Error> for GraphRenderError {
fn from(source: io::Error) -> Self {
Self::Io { source }
}
}
impl From<std::fmt::Error> for GraphRenderError {
fn from(source: std::fmt::Error) -> Self {
Self::Format { source }
}
}