Skip to main content

Crate guinea

Crate guinea 

Source
Expand description

guinea, assembled: the agnostic halves plus whichever backends this build renders with.

An application depends on this crate and nothing else: the macros are here, and what they expand to finds its way through here too. What almost every file needs is one import, use guinea::prelude::*;.

A backend arrives as a feature, and while exactly one is enabled it also arrives as [Backend] and [backend] - which routes! targets by default, so a single-backend application names its toolkit nowhere.

Enable two and that shorthand goes away on purpose: there is no sensible answer to “the backend” any more, and every route tree has to say which one it is for:

ⓘ
routes! {
    backend = guinea::ratatui::Tui,
    Route { .. }
}

With no backend at all what is left is the router, the application runtime and the macros - which is what a port to another toolkit starts from.

winui is a default feature and means nothing off Windows: there it enables no backend, so a build for Linux with ratatui added has ratatui as its one backend.

Re-exports§

pub use guinea_core::__private::anyhow;
pub use guinea_codegen as codegen;
pub use guinea_core as core;
pub use guinea_meta as meta;

Modules§

app
devtools
Every live router on this thread, readable without knowing its backend or its route type.
enter
Guards on the way in.
feature
headless
A backend that draws nothing.
lifecycle_tracker
link
What a deep link is allowed to carry.
manifest
The deep-link manifest: the external surface, written down and diffed.
prelude
What a feature, an actor and an application are written with, whatever they draw with: use guinea::prelude::*;.
restore
Writing a route down, and reading it back after a restart.
router
timers
Timers, owned by the context that set them up.
uri

Macros§

actor
Declares an actor’s manifest:
app_meta
This application’s identity, read from its manifest.
feature
A feature’s manifest: its name, and the reducers it exports.
ratelimit
routes
routes! { Route { layout(TabsLayout) { page(Processes) link("/:context/processes") { context: String } ... } } } - the tree’s {} nesting is the segment chain (no attribute stack to track); page(...)’s type also names the generated variant, so there’s one name per leaf, not two kept in sync by hand. Generates the enum itself plus path/parse (string <-> enum), RouteChain (enum -> segment chain), and ToUri (enum -> AppUri, just the generated .path() string parsed - no per-app glue needed).
rpc_bind

Traits§

Event
A type that travels over the global bus, where subscribers find it by its TypeId alone.
Mark
A name a backend puts on an element, where a test or a tool finds it again

Attribute Macros§

handler
Makes a function an actor’s handler for one message: impl Handler<M> written from its signature.
installs
The function that installs a feature: whatever it returns is the feature, its second argument is what it is installed with.
reducer
Makes a function a reducer: impl Reducer written from its signature. The state is what the first argument borrows mutably, the update is the second argument’s type:
segment
Writes type Installs = (); and the install that goes with it, for a page or layout that installs nothing.
test
#[guinea::test]: one test, run once per seed on a fresh app::Harness - which the test-utils feature brings. A test run once per seed, each time on a fresh Harness, with the order of everything it sets off decided by the seed.

Derive Macros§

Event
Puts a type on the global bus: impl Event for T {}.
Mark
Makes an enum of unit variants the application’s marks: each variant is a name, written as the variant is.
Remote
Lets a tool send this type to the running application as JSON: as an action to whichever scope answers it, as an event on the global bus, or both. The type derives serde::Deserialize too.