svgtypes/
lib.rs

1// Copyright 2018 the SVG Types Authors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4/*!
5*svgtypes* is a collection of parsers for [SVG](https://www.w3.org/TR/SVG2/) types.
6
7## Supported SVG types
8
9- [`<color>`](https://www.w3.org/TR/css-color-3/)
10- [`<number>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGNumber)
11- [`<length>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGLength)
12- [`<angle>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGAngle)
13- [`<viewBox>`](https://www.w3.org/TR/SVG2/coords.html#ViewBoxAttribute)
14- [`<path>`](https://www.w3.org/TR/SVG2/paths.html#PathData)
15- [`<transform>`](https://www.w3.org/TR/SVG11/types.html#DataTypeTransformList)
16- [`<list-of-numbers>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGNumberList)
17- [`<list-of-lengths>`](https://www.w3.org/TR/SVG2/types.html#InterfaceSVGLengthList)
18- [`<list-of-points>`](https://www.w3.org/TR/SVG11/shapes.html#PointsBNF)
19- [`<filter-value-list>`](https://www.w3.org/TR/filter-effects-1/#typedef-filter-value-list)
20- [`<paint>`](https://www.w3.org/TR/SVG2/painting.html#SpecifyingPaint)
21- [`<preserveAspectRatio>`](https://www.w3.org/TR/SVG11/coords.html#PreserveAspectRatioAttribute)
22- [`<enable-background>`](https://www.w3.org/TR/SVG11/filters.html#EnableBackgroundProperty)
23- [`<IRI>`](https://www.w3.org/TR/SVG11/types.html#DataTypeIRI)
24- [`<FuncIRI>`](https://www.w3.org/TR/SVG11/types.html#DataTypeFuncIRI)
25- [`paint-order`](https://www.w3.org/TR/SVG2/painting.html#PaintOrder)
26
27## Features
28
29- Complete support of paths, so data like `M10-20A5.5.3-4 110-.1` will be parsed correctly.
30- Implicit path commands will be automatically converted into explicit one.
31- Some SVG2 data types support.
32- Pretty fast.
33
34## Limitations
35
36- Accepts only [normalized](https://www.w3.org/TR/REC-xml/#AVNormalize) values,
37  e.g. an input text should not contain `&#x20;` or `&data;`.
38- All keywords must be lowercase.
39  Case-insensitive parsing is supported only for colors (requires allocation for named colors).
40- The `<color>` followed by the `<icccolor>` is not supported. As the `<icccolor>` itself.
41- [System colors](https://www.w3.org/TR/css3-color/#css2-system), like `fill="AppWorkspace"`,
42  are not supported. They were deprecated anyway.
43
44## Safety
45
46- The library should not panic. Any panic considered as a critical bug and should be reported.
47- The library forbids unsafe code.
48
49## Alternatives
50
51None.
52*/
53
54#![forbid(unsafe_code)]
55#![deny(missing_docs)]
56#![deny(missing_debug_implementations)]
57#![deny(missing_copy_implementations)]
58
59macro_rules! matches {
60    ($expression:expr, $($pattern:tt)+) => {
61        match $expression {
62            $($pattern)+ => true,
63            _ => false
64        }
65    }
66}
67
68mod angle;
69mod aspect_ratio;
70mod color;
71#[rustfmt::skip] mod colors;
72mod directional_position;
73mod enable_background;
74mod error;
75mod filter_functions;
76mod font;
77mod funciri;
78mod length;
79mod number;
80mod paint;
81mod paint_order;
82mod path;
83mod points;
84mod stream;
85mod transform;
86mod transform_origin;
87mod viewbox;
88
89use crate::stream::{ByteExt, Stream};
90
91pub use crate::angle::*;
92pub use crate::aspect_ratio::*;
93pub use crate::color::*;
94pub use crate::directional_position::*;
95pub use crate::enable_background::*;
96pub use crate::error::*;
97pub use crate::filter_functions::*;
98pub use crate::font::*;
99pub use crate::funciri::*;
100pub use crate::length::*;
101pub use crate::number::*;
102pub use crate::paint::*;
103pub use crate::paint_order::*;
104pub use crate::path::*;
105pub use crate::points::*;
106pub use crate::transform::*;
107pub use crate::transform_origin::*;
108pub use crate::viewbox::*;