Skip to main content

Module render

Module render 

Source
Expand description

Render trait and error type for command view rendering.

This module defines the shared interface that all command view structs implement. Every JsonView and TextView across all command modules implements Render<T>, providing compile-time enforcement of a consistent render signature.

§Design

The Render<T> trait is generic over the DTO type T so that each view module can bind it to its own view-data type:

impl Render<ConfigureDetailsData> for JsonView { ... }
impl Render<ConfigureDetailsData> for TextView { ... }

Using a dedicated ViewRenderError type (rather than serde_json::Error directly) decouples the presentation layer from the serialization backend. If the backend ever changes, only this module and its From impls need updating — not every call site.

§Error handling

Text renderers always return Ok — they do pure string formatting and never fail. JSON renderers call serde_json::to_string_pretty, which is expected to succeed for the plain #[derive(Serialize)] DTOs used in this project, but serialization errors are still possible (e.g. non-finite floats, non-string map keys, custom Serialize impls) and are propagated as ViewRenderError.

Enums§

ViewRenderError
Error produced by a Render implementation.

Traits§

Render
Trait for rendering command output data into a string.