Crate is_svg

Crate is_svg 

Source
Expand description

The is-svg crate is a library for testing whether a given data is a SVG image.

This crate assumes the given data to be a valid SVG image if usvg::Tree::from_data returns Ok, and an invalid SVG image if it returns Err. It supports both a SVG string and a gzip-compressed SVG data.

§Examples

assert_eq!(
    is_svg::is_svg(include_str!("../tests/data/w3/svg-logo-v.svg")),
    true
);
assert_eq!(
    is_svg::is_svg(include_bytes!("../tests/data/w3/svg-logo-v.png")),
    false
);

// `.svgz` is also supported.
assert_eq!(
    is_svg::is_svg(include_bytes!("../tests/data/w3/svg-logo-v.svgz")),
    true
);

Functions§

is_svg
Returns true if data is a valid SVG data, and false otherwise.
is_svg_string
Returns true if data is a valid non gzip-compressed SVG data (.svg), and false otherwise.
is_svgz
Returns true if data is a valid gzip-compressed SVG data (.svgz), and false otherwise.