Skip to main content

ResponseWriter

Trait ResponseWriter 

Source
pub trait ResponseWriter {
    // Required methods
    fn write(&mut self, content: &str) -> Result<(), HandlerError>;
    fn end(&mut self) -> Result<(), HandlerError>;

    // Provided methods
    fn write_escaped(&mut self, content: &str) -> Result<(), HandlerError> { ... }
    fn write_escaped_attribute(
        &mut self,
        name: &str,
        value: &str,
    ) -> Result<(), HandlerError> { ... }
}
Expand description

Interface for writing rendered output

Required Methods§

Source

fn write(&mut self, content: &str) -> Result<(), HandlerError>

Write content to the output

Source

fn end(&mut self) -> Result<(), HandlerError>

Finalize the output

Provided Methods§

Source

fn write_escaped(&mut self, content: &str) -> Result<(), HandlerError>

Write untrusted text with the same HTML escaping as encode_safe.

Buffered writers may override this to append encoded text directly without allocating an intermediate string.

Source

fn write_escaped_attribute( &mut self, name: &str, value: &str, ) -> Result<(), HandlerError>

Write a quoted HTML attribute, escaping its untrusted value.

The name must already be a valid, trusted attribute name. Implementations must preserve the six entity replacements used by encode_safe.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§