Skip to main content

Module toast

Module toast 

Expand description

Toast + ToastStack primitive — transient notifications anchored top-right of the shell, sinking fallible OS operations (trash/rename/move/copy), ShellError conversions, and confirmations.

The Widget impl draws each active toast as a stacked floating card with its severity icon and a dismiss control. The stack advances itself from crate::time: an app only pushes. Expiry pauses while the pointer is over the stack, and under the capture clock (--shots) so a scenario can hold a toast in frame.

Structs§

Notice
The one transient message an app shows over its content: a confirmation, something under way, or a failure. The app shows it and paints it where it belongs; the notice keeps its own lifetime and its announcement.
Toast
A single toast entry held by a ToastStack. Entries are produced internally by ToastStack::push; shell code does not construct Toast values directly.
ToastCard
Immediate-mode content for one notification / toast card, painted by paint_card. Built fluently: ToastCard::new("Slow network", ToastKind::Warning).body("retrying").
ToastCardHit
Geometry paint_card hands back so callers hit-test the card’s interactive regions against widget-owned rects (no bespoke maths).
ToastStack
Top-right notification stack with a configurable maximum entry count and TTL-based expiry.

Enums§

ToastAnchor
Placement for a transient card painted inside an app’s area.
ToastKind
Severity / category of a toast. Maps to the semantic color ramp in crate::tokens::Colors for the left accent bar.

Constants§

DEFAULT_MAX
Default maximum number of simultaneous toasts. When the cap is exceeded by ToastStack::push the oldest entry is dropped.
DEFAULT_TTL
Default time-to-live for a freshly pushed toast.
NOTICE_LIFETIME
How long a Notice stays up.

Functions§

minimum_card_height
Minimum height for a compact card with one elided line per text field. Uses the same normalized text, roles, padding and shared action controls as paint_card. A host choosing a fixed-width banner must reserve this height before stacking cards; enlarging type must not paint text over its actions.
paint_card
Paint a toast / notification card into rect and return the geometry a caller needs to route clicks. The card is width/height-agnostic (it lays out relative to rect), so a 48px single-line in-app toast and a 64px three-line OS notification share this one renderer.
paint_transient
Paint a transient toast in area, at anchor.
transient_expired
Whether a transient shown at shown for ttl has expired. Under the capture clock (--shots) nothing expires, so a scenario that stages a toast keeps it in frame.