Expand description
Deterministic, UI-independent validation and rasterization of application SVG icons.
Application icons have stricter size, square-shape, external-resource, and visible-alpha requirements than the legacy arbitrary-SVG adapter. Successful rasters are square premultiplied RGBA8 buffers. The process performs no network or filesystem I/O through this crate.
§Examples
use ailloli_ui_core::AppIcon;
use ailloli_ui_icon::{rasterize_app_icon, validate_app_icon};
const SVG: &[u8] = br#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><rect width="10" height="10"/></svg>"#;
let icon = AppIcon::from_static_svg(SVG, "assets/icon.svg");
assert_eq!(validate_app_icon(&icon).unwrap().width, 10.0);
assert_eq!(rasterize_app_icon(&icon, 32).unwrap().rgba.len(), 32 * 32 * 4);Structs§
- Rasterized
Icon - Square premultiplied RGBA8 raster output.
- Validated
Icon - Metadata produced after source, geometry, parse, and visible-alpha validation.
Enums§
- Icon
Error - Application-icon validation and raster allocation failures.
Constants§
- MAX_
SVG_ BYTES - Maximum accepted application-icon source length: 4 MiB (4,194,304 bytes).
- MAX_
SVG_ DIMENSION - Maximum accepted SVG view-box and parsed-tree dimension, in SVG/CSS pixels.
- SQUARE_
RELATIVE_ EPSILON - Maximum relative width/height delta treated as numerically square.
Functions§
- rasterize_
app_ icon - Validates and rasterizes an app icon, caching by source digest and side length.
- rasterize_
svg_ source - Rasterizes an arbitrary legacy SVG source without application-icon validation.
- validate_
app_ icon - Validates source size, XML/resource structure, square geometry, and visibility.