column

Layout atom declaring horizontal space intent within a Row.

struct Component

source

pub struct Component

A single cell within a Row that declares how much horizontal space it wants.

Column is a pure layout atom — it does NOT measure or resolve widths. That is the Row molecule’s responsibility. Column only stores the content and the flex intent.

Field Type Description
content String Rendered cell text, which may hold ANSI styling.
flex Flex How much horizontal space the cell asks the row for.

Implements Display.

Component::fixed

source

pub fn fixed(width: usize, content: impl Display) -> Self

Create a column that requests an exact character width.

Parameter Type Description
width usize the width in columns; the row pads narrower content to it and never cuts wider content
content impl Display the cell content, rendered to text now
returns Self The fixed-width column.

Component::flex

source

pub fn flex(weight: u32, content: impl Display) -> Self

Create a column that requests a proportional share of remaining space.

Parameter Type Description
weight u32 the column’s share relative to the other flex columns in the row
content impl Display the cell content, rendered to text now
returns Self The flex column.

Component::natural

source

pub fn natural(content: impl Display) -> Self

Create a column that requests exactly enough space for its content.

Parameter Type Description
content impl Display the cell content, rendered to text now
returns Self The natural-width column.

Component::content

source

pub fn content(&self) -> &str

Returns the content string.

Parameter Type Description
returns &str The content string.

Component::flex_intent

source

pub fn flex_intent(&self) -> Flex

Returns the flex intent for this column.

Parameter Type Description
returns Flex The flex intent for this column.

enum Flex

source

pub enum Flex

How a column requests horizontal space.

Variant Description
Fixed(usize) Requests an exact character width. Narrower content is padded; wider content is not cut.
Flex(u32) Requests a proportional share of remaining space after fixed and natural columns are allocated.
Natural Requests exactly enough space to fit its content.

Implements Clone, Copy, Debug.