Skip to main content

Column

Struct Column 

Source
pub struct Column<'a> {
    pub name: &'a str,
    pub width: Width,
    pub priority: Priority,
    pub kind: ColumnKind,
    pub min: Option<u16>,
    pub sortable: bool,
    pub sorted: Option<Sort>,
}
Expand description

One column of a table.

Described once. The grid track, the cell order and the drop behaviour are all derived from this, rather than being three hand-written encodings that must agree and are never checked against each other.

Fields§

§name: &'a str

The heading, and the name the cell is addressed by.

§width: Width

How much room it asks for.

§priority: Priority

What it is worth when room runs out.

§kind: ColumnKind

What the column holds, which is what carries its look.

§min: Option<u16>

The narrowest the column may be before it drops, in ch.

wiki frontend-unification: collapse points derive from declared minimums only, so every host narrows at the same declared width rather than at its own breakpoints. ch because every host has a direct answer for it: a terminal cell is one, an immediate-mode painter measures one off its face, and a webview draws one as nine sixteenths of the base, a figure at a table’s text size with room to spare. Not the CSS ch itself, because a container condition resolves font-relative units against a different font than the cell’s, and the column would hide at one width and be sized at another.

None derives it from the kind and the heading, which is what most columns want. Read it through floor, never directly: that is where the derivation, the rounding and the ceiling live, and a host reading this field would narrow somewhere the other two do not.

§sortable: bool

Whether the user can reorder the table by this column.

What reordering calls is not here — that is an address, and this crate names none — so a host pairs this with the route the way it pairs a row’s parts with the row’s activation. This says the affordance exists, which is what a renderer needs to draw a header a user can press rather than a heading they cannot.

§sorted: Option<Sort>

Which way the table is ordered by this column, if it is.

None on every column but the one in force. A renderer draws the caret from this and a webview sets aria-sort, which is why it is per column rather than a single fact on the table: the host idiom is a property of the header cell.

Independent of sortable rather than implied by it, because both combinations mean something. A column sorted and not sortable is a list ordered by a key the user cannot change, which is a real thing to describe and a caret worth drawing.

Implementations§

Source§

impl<'a> Column<'a>

Source

pub const fn new(name: &'a str) -> Self

A column that absorbs slack and drops after the optional ones.

Source

pub const fn min(self, ch: u16) -> Self

The same column, declaring the narrowest it may be before it drops.

Source

pub const fn floor(&self) -> u16

The narrowest this column may be before it drops, in ch.

What every host narrows by: a column is kept at a cutoff only while the floors of every column kept there fit. The declared min, or else the widest of the kind’s floor, the heading with two for its capitals and two more for a caret, and sixteen for a Width::Fill column. Rounded up to an even count and held under MIN_CEILING, so a webview can carry the whole range as a fixed ladder of classes and the other two hosts round the same way.

Source

pub const fn kept_at(&self, cutoff: Priority) -> bool

Whether this column survives at the given cutoff.

A renderer narrows by raising the cutoff, and never by counting positions.

Trait Implementations§

Source§

impl<'a> Clone for Column<'a>

Source§

fn clone(&self) -> Column<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Column<'a>

Source§

impl<'a> Debug for Column<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for Column<'a>

Source§

impl<'a> Hash for Column<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for Column<'a>

Source§

fn eq(&self, other: &Column<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Column<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Column<'a>

§

impl<'a> RefUnwindSafe for Column<'a>

§

impl<'a> Send for Column<'a>

§

impl<'a> Sync for Column<'a>

§

impl<'a> Unpin for Column<'a>

§

impl<'a> UnsafeUnpin for Column<'a>

§

impl<'a> UnwindSafe for Column<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.