Skip to main content

LayoutDecision

Enum LayoutDecision 

Source
pub enum LayoutDecision {
#[non_exhaustive]
PriorityDrop { id: Cow<'static, str>, priority: u8, terminal_width: u16, overflow: u32, dropped_width: u16, },
#[non_exhaustive]
ShrinkApplied { id: Cow<'static, str>, from: u16, to: u16, target: u16, },
#[non_exhaustive]
ReflowApplied { id: Cow<'static, str>, from: u16, to: u16, target: u16, },
#[non_exhaustive]
WidthBoundUnderMinDrop { id: Cow<'static, str>, rendered_width: u16, min: u16, },
#[non_exhaustive]
WidthBoundOverMaxTruncate { id: Cow<'static, str>, rendered_width: u16, max: u16, }, }
Expand description

Event emitted by the layout engine when it takes one of five decisions under width pressure. The id field on every variant is borrowed from [crate::segments::LineItem::Segment.id] (per ADR-0026); built-in segment ids carry as Cow::Borrowed so the production path stays allocation-free.

Engine emit sites use the pub(crate) constructors below to pick up the debug_assert!’d width-relation invariants for free.

Variants§

§

#[non_exhaustive]
PriorityDrop

The reflow loop dropped a segment outright (no shrink form via try_shrink, no truncatable end-ellipsis feasible via try_reflow, or simply not truncatable). Fires whenever the engine removes a segment under width pressure.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§id: Cow<'static, str>
§priority: u8

Engine defaults().priority at drop time. > 0 (priority-0 is pinned per highest_priority_droppable).

§terminal_width: u16

Terminal cell budget at the call site (apply_layout’s terminal_width parameter).

§overflow: u32

total_width() - budget at loop entry; >= 1. u32 mirrors total_width()’s overflow-safe accumulator so a layout with many wide segments can’t wrap u16.

§dropped_width: u16

Pre-drop rendered.width of the segment removed (not the line delta). May be 0 — empty-render segments are valid drop targets when separator pressure forces slot removal.

§

#[non_exhaustive]
ShrinkApplied

try_shrink returned a valid compact render. from is the pre-shrink width, to is the post-shrink width, target is the width the reflow loop asked the segment to fit under. Invariant: to <= target < from.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§id: Cow<'static, str>
§from: u16
§to: u16
§target: u16
§

#[non_exhaustive]
ReflowApplied

try_reflow succeeded with an end-ellipsis on a truncatable segment. Same from/to/target shape as ShrinkApplied.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§id: Cow<'static, str>
§from: u16
§to: u16
§target: u16
§

#[non_exhaustive]
WidthBoundUnderMinDrop

apply_width_bounds returned None because the rendered width fell below the configured width.min — the segment is hidden rather than displayed at a wrong width.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§id: Cow<'static, str>
§rendered_width: u16
§min: u16
§

#[non_exhaustive]
WidthBoundOverMaxTruncate

apply_width_bounds clipped a too-wide render via truncate_to (end-ellipsis) because rendered_width > max. Emitted at the apply_width_bounds call site, NOT inside truncate_to itself (which is also reached from try_reflow, where the emit is ReflowApplied).

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§id: Cow<'static, str>
§rendered_width: u16
§max: u16

Implementations§

Source§

impl LayoutDecision

Source

pub fn remediation(&self) -> Option<&'static str>

Engine-recommended remediation phrasing for the decision, or None when the decision doesn’t have a user-actionable fix. Returns &'static str because every remediation is a literal; reach for format! and the signature stops compiling, which keeps the table in one place and testable.

Per-variant match (no _ arm) so a future sixth variant forces the author to declare its remediation intent at compile time rather than silently inheriting None.

Trait Implementations§

Source§

impl Clone for LayoutDecision

Source§

fn clone(&self) -> LayoutDecision

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 Debug for LayoutDecision

Source§

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

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

impl PartialEq for LayoutDecision

Source§

fn eq(&self, other: &LayoutDecision) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for LayoutDecision

Source§

impl StructuralPartialEq for LayoutDecision

Auto Trait Implementations§

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.