vexy-vsvg 2.2.6

Core library for vexy-vsvg SVG optimizer
docs.rs failed to build vexy-vsvg-2.2.6
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: vexy-vsvg-0.1.0

Vexy Vsvg VSVG

SVG optimization for Rust. Parse → optimize → stringify.

Feed it bloated SVGs from Illustrator, Figma, or Inkscape; get back lean, identical-looking output. Same plugin names and config format as SVGO, but compiled to native code.

How it works

SVG text → Parser (quick-xml) → Document AST → 52 plugins → Stringifier → SVG text
  • Parsing: Turns XML into a mutable [Document] tree with [Element] nodes.
  • Plugins: 52 optimization passes — each implements the [Plugin] trait and walks the AST via the Visitor pattern.
  • Optimization: Runs enabled plugins in order, with optional multipass until the output stabilizes.
  • Stringification: Converts the AST back to XML, minified or pretty-printed.

Usage

Add this to your Cargo.toml:

[dependencies]
vexy-vsvg = "2.1.1"

Optimize an SVG string with default settings:

use vexy_vsvg::{optimize_default, VexyError};

fn main() -> Result<(), VexyError> {
    let svg = r#"<svg><rect width="100" height="100"/></svg>"#;
    let result = optimize_default(svg)?;
    
    println!("Optimized: {}", result.data);
    Ok(())
}

Configure specific plugins:

use vexy_vsvg::{optimize, Config, PluginConfig};

let mut config = Config::default();
config.plugins.push(PluginConfig::Name("removeDimensions".to_string()));

let svg = r#"<svg viewBox="0 0 10 10" width="10" height="10">...</svg>"#;
let result = optimize(svg, config.into()).unwrap();

Modules

Module Role
[ast] The mutable document tree — [Document], [Element], [Node]
[parser] SVG text → AST (uses quick-xml under the hood)
[optimizer] The pipeline: parse → apply plugins → stringify
[stringifier] AST → SVG text (minified or pretty-printed)
[plugin_registry] Registry of named plugin factories
[visitor] Tree-walking framework for plugins
[css] CSS variable resolution for var() references
[collections] SVG element/attribute metadata tables
[utils] Shared helpers for colors, numbers, paths, selectors
[error] The unified [VexyError] type
[features] Compile-time feature flags and runtime capability queries