Trait style_traits::values::ToCss
[−]
[src]
pub trait ToCss { fn to_css<W>(&self, dest: &mut W) -> Result
where
W: Write; fn to_css_string(&self) -> String { ... } }
Serialises a value according to its CSS representation.
This trait is implemented for str
and its friends, serialising the string
contents as a CSS quoted string.
This trait is derivable with #[derive(ToCss)]
, with the following behaviour:
* unit variants get serialised as the snake-case
representation
of their name;
* unit variants whose name starts with "Moz" or "Webkit" are prepended
with a "-";
* if #[css(comma)]
is found on a variant, its fields are separated by
commas, otherwise, by spaces;
* if #[css(function)]
is found on a variant, the variant name gets
serialised like unit variants and its fields are surrounded by parentheses;
* if #[css(iterable)]
is found on a function variant, that variant needs
to have a single member, and that member needs to be iterable. The
iterable will be serialized as the arguments for the function.
* if #[css(dimension)]
is found on a variant, that variant needs
to have a single member. The variant would be serialized as a CSS
dimension token, like: #[css(derive_debug)]
on the whole type, to
implement Debug
by a single call to ToCss::to_css
.
Required Methods
fn to_css<W>(&self, dest: &mut W) -> Result where
W: Write,
W: Write,
Serialize self
in CSS syntax, writing to dest
.
Provided Methods
fn to_css_string(&self) -> String
Serialize self
in CSS syntax and return a string.
(This is a convenience wrapper for to_css
and probably should not be overridden.)
Implementations on Foreign Types
impl<'a, T: ?Sized> ToCss for &'a T where
T: ToCss,
[src]
T: ToCss,
impl ToCss for str
[src]
impl ToCss for String
[src]
impl<T> ToCss for Option<T> where
T: ToCss,
[src]
T: ToCss,
impl<T> ToCss for Vec<T> where
T: ToCss + OneOrMoreSeparated,
[src]
T: ToCss + OneOrMoreSeparated,
impl<T: ?Sized> ToCss for Box<T> where
T: ToCss,
[src]
T: ToCss,
impl<T: ?Sized> ToCss for Arc<T> where
T: ToCss,
[src]
T: ToCss,
impl ToCss for Au
[src]
impl<'a> ToCss for f32
[src]
impl<'a> ToCss for i32
[src]
impl<'a> ToCss for u16
[src]
impl<'a> ToCss for u32
[src]
impl<'a> ToCss for Token<'a>
[src]
impl<'a> ToCss for RGBA
[src]
impl<'a> ToCss for Color
[src]
impl<'a> ToCss for UnicodeRange
[src]
Implementors
impl ToCss for Cursor
impl ToCss for UserZoom
impl ToCss for Orientation
impl ToCss for ViewportConstraints
impl ToCss for Zoom