Expand description
Representation of the <color>
type.
Fields
red: u8
green: u8
blue: u8
Implementations
Trait Implementations
sourceimpl From<Color> for AttributeValue
impl From<Color> for AttributeValue
sourcefn from(value: Color) -> AttributeValue
fn from(value: Color) -> AttributeValue
Converts to this type from the input type.
sourceimpl FromStr for Color
impl FromStr for Color
sourcefn from_str(text: &str) -> Result<Color, Error>
fn from_str(text: &str) -> Result<Color, Error>
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>
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.
sourceimpl WriteBuffer for Color
impl WriteBuffer for Color
sourcefn write_buf_opt(&self, opt: &WriteOptions, buf: &mut Vec<u8, Global>)
fn write_buf_opt(&self, opt: &WriteOptions, buf: &mut Vec<u8, Global>)
Writes data to the
Vec<u8>
buffer using specified WriteOptions
.sourcefn write_buf(&self, buf: &mut Vec<u8, Global>)
fn write_buf(&self, buf: &mut Vec<u8, Global>)
Writes data to the
Vec<u8>
buffer using default WriteOptions
.sourcefn with_write_opt<'a>(&'a self, opt: &'a WriteOptions) -> DisplaySvg<'a, Self>where
Self: Sized,
fn with_write_opt<'a>(&'a self, opt: &'a WriteOptions) -> DisplaySvg<'a, Self>where
Self: Sized,
Returns an object that implements
fmt::Display
using provided write options.impl Copy for Color
impl StructuralPartialEq for Color
Auto Trait Implementations
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more