Struct svgparser::Color
[−]
[src]
pub struct Color { pub red: u8, pub green: u8, pub blue: u8, }
Representation of the <color>
type.
Fields
red: u8
green: u8
blue: u8
Methods
impl Color
[src]
pub fn new(red: u8, green: u8, blue: u8) -> Color
[src]
Constructs a new Color
from red
, green
and blue
values.
pub fn from_span(span: StrSpan) -> Result<Color, StreamError>
[src]
Parses Color
from StrSpan
.
Parsing is done according to spec:
color ::= "#" hexdigit hexdigit hexdigit (hexdigit hexdigit hexdigit)?
| "rgb(" wsp* integer comma integer comma integer wsp* ")"
| "rgb(" wsp* integer "%" comma integer "%" comma integer "%" wsp* ")"
| color-keyword
hexdigit ::= [0-9A-Fa-f]
comma ::= wsp* "," wsp*
* The SVG spec has an error. There should be number
,
not an integer
for percent values (details).
Errors
-
Returns error if a color has an invalid format.
-
Returns error if
color-keyword
orrgb
prefix are in in the lowercase. It's not supported. -
Returns error if
<color>
is followed by<icccolor>
. It's not supported.
Notes
- Any non-
hexdigit
bytes will be treated as0
. - Allocates heap memory for case-insensitive named colors comparison.
Trait Implementations
impl Copy for Color
[src]
impl Clone for Color
[src]
fn clone(&self) -> Color
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq for Color
[src]
fn eq(&self, __arg_0: &Color) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Color) -> bool
[src]
This method tests for !=
.
impl Debug for Color
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl FromStr for Color
[src]
type Err = StreamError
The associated error which can be returned from parsing.
fn from_str(text: &str) -> Result<Self, StreamError>
[src]
Parses a string s
to return a value of this type. Read more