Skip to main content

ggplot_rs/render/
mod.rs

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