Expand description
Derive macros for the gilt terminal formatting library.
This crate provides the #[derive(Table)], #[derive(Panel)], #[derive(Tree)],
#[derive(Columns)], #[derive(Rule)], #[derive(Inspect)], and #[derive(Renderable)] macros that generate widget
conversion methods and trait implementations for structs.
§Table Example
ⓘ
use gilt::Table;
#[derive(Table)]
#[table(title = "Employees", box_style = "ROUNDED", header_style = "bold cyan")]
struct Employee {
#[column(header = "Full Name", style = "bold")]
name: String,
#[column(justify = "right")]
age: u32,
#[column(skip)]
internal_id: u64,
#[column(header = "Dept", style = "green", min_width = 10)]
department: String,
}
let employees = vec![
Employee {
name: "Alice".into(),
age: 30,
internal_id: 1001,
department: "Engineering".into(),
},
Employee {
name: "Bob".into(),
age: 25,
internal_id: 1002,
department: "Marketing".into(),
},
];
let table = Employee::to_table(&employees);§Panel Example
ⓘ
use gilt::Panel;
#[derive(Panel)]
#[panel(title = "Server Status", box_style = "ROUNDED", border_style = "blue")]
struct ServerStatus {
#[field(label = "Host", style = "bold cyan")]
name: String,
#[field(label = "CPU %", style = "yellow")]
cpu: f32,
#[field(skip)]
internal_id: u64,
#[field(label = "Memory", style = "green")]
memory: f32,
}
let status = ServerStatus {
name: "web-01".into(),
cpu: 42.5,
internal_id: 1001,
memory: 67.3,
};
let panel = status.to_panel();Derive Macros§
- Columns
- Derive macro generating
to_columns(items: &[Self]) -> gilt::columns::Columns. See [crate::columns] for full attribute schema. - Inspect
- Derive macro that generates a
to_inspect(&self) -> gilt::inspect::Inspectmethod for structs implementingDebug. See [crate::inspect] for the full attribute schema. - Panel
- Derive macro generating
to_panel(&self) -> gilt::panel::Panel. See [crate::panel] for full attribute schema. - Renderable
- Derive macro that generates a
gilt::console::Renderableimplementation for a struct, delegating to one of the existing widget derives. - Rule
- Derive macro that generates a
to_rule(&self) -> gilt::rule::Rulemethod. See [crate::rule] for the full attribute schema. - Table
- Derive macro generating
to_table(items: &[Self]) -> gilt::table::Table. See [crate::table] for full attribute schema. - Tree
- Derive macro generating
to_tree(&self) -> gilt::tree::Tree. See [crate::tree] for full attribute schema.