Skip to main content

ggplot_rs/render/
mod.rs

1pub mod backend;
2pub mod layout;
3pub mod plotters_backend;
4pub mod renderer;
5
6/// A rectangle in pixel coordinates.
7#[derive(Clone, Debug)]
8pub struct Rect {
9    pub x: f64,
10    pub y: f64,
11    pub width: f64,
12    pub height: f64,
13}
14
15/// Rendering error type.
16#[derive(Debug)]
17pub enum RenderError {
18    MissingAesthetic(String),
19    BackendError(String),
20    IoError(std::io::Error),
21}
22
23impl std::fmt::Display for RenderError {
24    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25        match self {
26            RenderError::MissingAesthetic(a) => write!(f, "Missing required aesthetic: {a}"),
27            RenderError::BackendError(e) => write!(f, "Backend error: {e}"),
28            RenderError::IoError(e) => write!(f, "IO error: {e}"),
29        }
30    }
31}
32
33impl std::error::Error for RenderError {}
34
35impl From<std::io::Error> for RenderError {
36    fn from(e: std::io::Error) -> Self {
37        RenderError::IoError(e)
38    }
39}