pub struct Printer<'a, 'b, 'c, W> { /* private fields */ }
Expand description

A Printer represents a destination to output serialized CSS, as used in the ToCss trait. It can wrap any destination that implements std::fmt::Write, such as a String.

A Printer keeps track of the current line and column position, and uses this to generate a source map if provided in the options.

Printer also includes helper functions that assist with writing output that respects options such as minify, and css_modules.

Implementations§

Create a new Printer wrapping the given destination.

Returns the current source filename that is being printed.

Writes a raw string to the underlying destination.

NOTE: Is is assumed that the string does not contain any newline characters. If such a string is written, it will break source maps.

Write a single character to the underlying destination.

Writes a single whitespace character, unless the minify option is enabled.

Use write_char instead if you wish to force a space character to be written, regardless of the minify option.

Writes a delimeter character, followed by whitespace (depending on the minify option). If ws_before is true, then whitespace is also written before the delimeter.

Writes a newline character followed by indentation. If the minify option is enabled, then nothing is printed.

Increases the current indent level.

Decreases the current indent level.

Increases the current indent level by the given number of characters.

Decreases the current indent level by the given number of characters.

Returns whether the indent level is greater than one.

Adds a mapping to the source map, if any.

Writes a CSS identifier to the underlying destination, escaping it as appropriate. If the css_modules option was enabled, then a hash is added, and the mapping is added to the CSS module.

Returns an error of the given kind at the provided location in the current source file.

Trait Implementations§

Writes a string slice into this writer, returning whether the write succeeded. Read more
Writes a char into this writer, returning whether the write succeeded. Read more
Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Deserializes using the given deserializer

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type for metadata in pointers and references to Self.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.