1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! `render_table` / `render_json` — uniform structured-output
//! helpers consumed by the v0.4 `--output text|json` flag.
use Serialize;
use Style;
use ;
use crateRenderError;
/// Render `rows` as a `tabled` text table with the canonical v0.1
/// style. Returns the rendered string with a trailing newline so
/// callers can `print!` directly.
///
/// The style is fixed (`Style::psql()`) and there is no theming
/// parameter; item W2 of [spec 0020] records why.
///
/// [spec 0020]: https://gitlab.com/phpboyscout/rust-tool-base/-/wikis/specs/0020-rtb-tui-v0.1
/// Render `rows` as a pretty-printed JSON array (one element per
/// row, two-space indent, trailing newline).
///
/// # Errors
///
/// [`RenderError::Json`] when any row fails to serialise: a map key
/// that is not string-like (a tuple, say), or a `Serialize` impl that
/// returns an error. Non-finite floats serialise as `null` and integer
/// keys are stringified, so neither fails. The payload is a
/// stringified `serde_json::Error`.