Skip to main content

Crate snora

Crate snora 

Source
Expand description

§snora

The iced engine for the Snora GUI framework.

This crate binds snora_core vocabulary to iced. It exposes a single entry point, [render], a toast lifecycle helper module, and — when the widgets feature is enabled (the default) — a re-exported set of prefab iced::Element builders from the snora-widgets crate.

§Layering

Your application
        │
        ▼
 snora::render(AppLayout<Element, Message>) -> Element
        │
        ├─► snora-widgets   (optional, prefab UI parts)
        ▼
 snora-core   (vocabulary: Toast, Dialog, Sheet, SheetSize, …)

The dependency graph above is strict and the only way crates relate to each other:

  • snora-core has zero iced dependency. It owns the vocabulary (what choices exist).
  • snora-widgets depends on snora-core and iced. It owns the prefab widget visuals.
  • snora depends on snora-core and (optionally) snora-widgets. It owns the engine — render, the layer composition, and the toast lifecycle helpers.

Applications normally only depend on snora and use it as the single umbrella crate; the workspace split exists so each layer can evolve at its own pace.

§A minimal application view

use iced::{Element, widget::text};
use snora::{AppLayout, render, LayoutDirection};

fn view(state: &MyState) -> Element<'_, Message> {
    let body: Element<'_, Message> = text("Hello, snora!").into();

    let layout = AppLayout::new(body)
        .direction(LayoutDirection::Ltr);

    render(layout)
}

§Engine-only builds

Applications that supply 100 % of their UI parts and do not want the prefab widgets compiled in can opt out:

[dependencies]
snora = { version = "0.6", default-features = false }

In this configuration snora-widgets is not pulled in and the snora::widget module does not exist.

Re-exports§

pub use render::render;

Modules§

directionwidgets
Direction-aware row helpers. Re-exported from snora-widgets. Direction-aware layout helpers.
render
The single rendering entry point: [render]. The engine: turn an AppLayout into an iced::Element.
stylewidgets
Shared style functions used by the prefab widgets. Re-exported from snora-widgets. Shared styling for snora’s built-in widgets.
toast
Toast rendering and lifecycle helpers (subscription, sweep_expired). Toast rendering and lifecycle utilities.
widgetwidgets
Optional prefab iced::Element builders for header / sidebar / footer / menu / icon. Re-exported from snora-widgets.

Structs§

AppLayout
The complete declarative description of what should be on screen.
Crumb
One step in a breadcrumb trail.
Dialog
A modal dialog.
Menu
A top-level menu in the header (e.g. “File”, “View”).
MenuItem
A single entry in a menu’s dropdown.
Sheet
A panel that slides in from one of the window edges.
SideBar
The vertical navigation rail as a whole.
SideBarItem
One entry in a sidebar.
Tab
One tab in a TabBar. Carries an application-defined TabId so that the application is the source of truth for which tab is which.
TabBar
A horizontal tab strip.
Toast
A toast notification.

Enums§

BreadcrumbAction
What happens when the user interacts with the breadcrumb trail.
Edge
A logical position along a primary axis.
Icon
An icon, with feature-gated source variants.
LayoutDirection
Reading direction of the application’s layout.
MenuAction
An event emitted by a header menu.
SheetEdge
Which window edge a sheet attaches to.
SheetSize
The size a sheet should occupy along the axis perpendicular to its anchor edge.
TabAction
What happens when the user interacts with a tab.
ToastIntent
Semantic intent of a notification.
ToastLifetime
Auto-dismiss policy for a toast.
ToastPosition
Where the toast stack anchors within the window.