kroki_rs/interface/dtos.rs
1use serde::{Deserialize, Serialize};
2
3/// DTO for a diagram rendering request.
4/// Decouples external input (HTTP/CLI) from the internal domain models.
5#[derive(Debug, Serialize, Deserialize, Clone)]
6pub struct RenderRequestDto {
7 /// The source content of the diagram (plain text).
8 pub source: String,
9
10 /// The target output format (e.g., "svg", "png").
11 #[serde(skip_serializing_if = "Option::is_none")]
12 pub format: Option<String>,
13
14 /// The diagram engine/provider (e.g., "mermaid", "graphviz").
15 #[serde(skip_serializing_if = "Option::is_none")]
16 pub provider: Option<String>,
17
18 /// Optional width for the output image.
19 #[serde(skip_serializing_if = "Option::is_none")]
20 pub width: Option<u32>,
21
22 /// Optional height for the output image.
23 #[serde(skip_serializing_if = "Option::is_none")]
24 pub height: Option<u32>,
25}
26
27/// DTO for a successful diagram rendering response.
28#[derive(Debug, Serialize, Deserialize, Clone)]
29pub struct RenderResponseDto {
30 /// The rendered output (e.g., SVG text or base64-encoded image).
31 pub result: String,
32
33 /// The content type of the result (e.g., "image/svg+xml").
34 pub content_type: String,
35
36 /// Rendering duration in milliseconds.
37 pub duration_ms: u64,
38}