Skip to main content

svg_renderer/
error.rs

1#[cfg(feature = "vulkan-backend")]
2use ash::vk;
3
4/// Errors that can occur during SVG rendering.
5#[derive(Debug, thiserror::Error)]
6pub enum SvgRenderError {
7    /// The requested render dimensions are zero or exceed `i32::MAX`.
8    #[error("invalid render size {width}x{height}")]
9    InvalidSize { width: u32, height: u32 },
10
11    /// Pipeline worker count is 0; at least 1 worker is required.
12    #[error("invalid pipeline worker count {workers}; expected at least 1")]
13    InvalidWorkerCount { workers: usize },
14
15    /// Failed to load the Vulkan shared library (e.g. `vulkan-1.dll`).
16    #[cfg(feature = "vulkan-backend")]
17    #[error("failed to load Vulkan loader: {0}")]
18    VulkanLoader(#[from] ash::LoadingError),
19
20    /// A raw Vulkan API call returned an error code.
21    #[cfg(feature = "vulkan-backend")]
22    #[error("Vulkan call failed: {0:?}")]
23    Vulkan(#[from] vk::Result),
24
25    /// No physical device with a graphics queue family was found.
26    #[cfg(feature = "vulkan-backend")]
27    #[error("no Vulkan physical device with graphics queue was found")]
28    NoVulkanDevice,
29
30    /// Skia failed to create a Vulkan-backed direct rendering context.
31    #[cfg(feature = "vulkan-backend")]
32    #[error("failed to create Skia Vulkan direct context")]
33    SkiaContext,
34
35    /// The SVG document could not be parsed by Skia's SVG DOM parser.
36    #[error("failed to parse SVG")]
37    SvgParse,
38
39    /// Skia failed to allocate the raster or GPU render target surface.
40    #[error("failed to create render target")]
41    RenderTarget,
42
43    /// Pixel readback from the render surface failed.
44    #[error("failed to read pixels from render target")]
45    ReadPixels,
46
47    /// PNG encoding via Skia failed.
48    #[error("failed to encode PNG")]
49    PngEncode,
50
51    /// JPEG encoding via Skia failed.
52    #[error("failed to encode JPEG")]
53    JpegEncode,
54
55    /// WebP encoding via Skia failed.
56    #[error("failed to encode WebP")]
57    WebpEncode,
58
59    /// The pipeline worker thread exited before the render job completed.
60    #[error("pipeline renderer worker stopped before completing the render job")]
61    PipelineClosed,
62}