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.
- 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
- services
- What plugins provided, reached the same way from wherever it can be.
- timers
- Timers, owned by the context that set them up.
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.
- 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,linkanddeep_linksfor the routes that agreed to have an address, andRouteChain(enum -> segment chain).- rpc_
bind Deprecated
Traits§
- Event
- A type that travels over the global bus, where subscribers find it by its
TypeIdalone. - Mark
- A name a backend puts on an element, where a test or a tool finds it again
- Request
- A request on the global bus, and what answers it. Written with
#[derive(guinea::Request)]and#[request(reply = Type)]. - Services
- A context that can hand out what plugins provided at startup: a feature’s
FeatureInitContext, aPluginBuilder, a harness segment, a route’s enter guard.
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 Reducerwritten 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 theinstallthat goes with it, for a page or layout that installs nothing. - test
#[guinea::test]: one test, run once per seed on a freshapp::Harness- which thetest-utilsfeature brings. A test run once per seed, each time on a freshHarness, 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::Deserializetoo. - Request
- Makes a type a request on the global bus, answered with
reply: the request names its answer where the request is declared.