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: . * finally, one can put #[css(derive_debug)] on the whole type, to implement Debug by a single call to ToCss::to_css.

Required Methods

Serialize self in CSS syntax, writing to dest.

Provided Methods

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]

[src]

[src]

impl ToCss for str
[src]

[src]

[src]

impl ToCss for String
[src]

[src]

[src]

impl<T> ToCss for Option<T> where
    T: ToCss
[src]

[src]

[src]

impl<T> ToCss for Vec<T> where
    T: ToCss + OneOrMoreSeparated
[src]

[src]

[src]

impl<T: ?Sized> ToCss for Box<T> where
    T: ToCss
[src]

[src]

[src]

impl<T: ?Sized> ToCss for Arc<T> where
    T: ToCss
[src]

[src]

[src]

impl ToCss for Au
[src]

[src]

[src]

impl<'a> ToCss for f32
[src]

[src]

[src]

impl<'a> ToCss for i32
[src]

[src]

[src]

impl<'a> ToCss for u16
[src]

[src]

[src]

impl<'a> ToCss for u32
[src]

[src]

[src]

impl<'a> ToCss for Token<'a>
[src]

[src]

[src]

impl<'a> ToCss for RGBA
[src]

[src]

[src]

impl<'a> ToCss for Color
[src]

[src]

[src]

impl<'a> ToCss for UnicodeRange
[src]

[src]

[src]

Implementors