ron
to a table.It uses tabled
as a rendering backend.
The library supports 2 modes for a table embeded and collapsed. It also provides with a list of options to modify the table, such as style, alignment, padding and more.
You can change an orientation of a map
and sequence
via Orientation
.
You'll find to examples for the modes bellow.
Add the library to a dependency list.
toml
[dependencies]
ron_to_table = "0.1.0"
Example (embeded) | Result |
---|---|
```rust let data = r#"Scene( materials: { "metal": (reflectivity: 1.0), "plastic": (reflectivity: 0.5), }, entities: [ (name: "hero", material: "metal"), (name: "monster", material: "plastic"), ], )"#; let scene = ron::from_str(data).unwrap(); let table = ron_to_table::to_string(&scene); println!("{}", table); ``` | ```text +-------------+--------------------------------------------+ | entities | +----------------------------+ | | | | +------------+---------+ | | | | | | material | metal | | | | | | +------------+---------+ | | | | | | name | hero | | | | | | +------------+---------+ | | | | +----------------------------+ | | | | +------------+-----------+ | | | | | | material | plastic | | | | | | +------------+-----------+ | | | | | | name | monster | | | | | | +------------+-----------+ | | | | +----------------------------+ | +-------------+--------------------------------------------+ | materials | +-----------+----------------------------+ | | | | metal | +----------------+-----+ | | | | | | | reflectivity | 1 | | | | | | | +----------------+-----+ | | | | +-----------+----------------------------+ | | | | plastic | +----------------+-------+ | | | | | | | reflectivity | 0.5 | | | | | | | +----------------+-------+ | | | | +-----------+----------------------------+ | +-------------+--------------------------------------------+ ``` |
Example (collapsed) | Result |
---|---|
```rust use rontotable::RonTable; use tabled::settings::Style; let scene = ron::from_str( r#" Scene( materials: { "metal": (reflectivity: 1.0), "plastic": (reflectivity: 0.5), }, entities: [ (name: "hero", material: "metal"), (name: "monster", material: "plastic"), ], ) "#, ) .unwrap(); let table = RonTable::default() .collapse() .with(Style::extended()) .build(&scene); println!("{table}"); ``` |
|