Expand description
Views for Render Command
This module contains view components for rendering render command output.
§Architecture
This module follows the Strategy Pattern for rendering:
RenderDetailsData: The data DTO passed to all viewsTextView: Renders human-readable text outputJsonView: Renders machine-readable JSON output
§Structure
view_data/: Data structures (DTOs) passed to viewsrender_details.rs: Main DTO with render result data
views/: View rendering implementationstext_view.rs: Human-readable text renderingjson_view.rs: Machine-readable JSON rendering
§SOLID Principles
- Single Responsibility: Each view has one job - render in its format
- Open/Closed: Add new formats by creating new view files, not modifying existing ones
- Strategy Pattern: Different rendering strategies for the same data
§Adding New Formats
To add a new output format (e.g., XML, YAML, CSV):
- Create a new file in
views/:xml_view.rs,yaml_view.rs, etc. - Implement the view with
render(data: &RenderDetailsData) -> String - Export it from this module
- No need to modify existing views or the DTO
Re-exports§
pub use view_data::RenderDetailsData;pub use views::JsonView;pub use views::TextView;