Expand description
A router for GPUI applications, providing declarative routing capabilities.
Structs§
- Location
- A Location represents a URL-like location in the router. It contains a pathname and an optional state object.
- NavLink
- A navigation link that changes the route when clicked.
- Outlet
- A placeholder element for routed components. When no component is routed to this outlet, it renders as an empty element.
- Path
Match - A PathMatch contains info about how a PathPattern matched on a URL-like pathname.
- Route
- Configures an element to render when a pattern matches the current path.
It must be rendered within a
Routeselement. - Router
- A simple router component that can hold child elements.
- Router
State - The global state of the router, including the current location, path match, and parameters. This state is stored globally within the GPUI application context.
- Routes
- Renders a branch of
Routethat best matches the current path.
Traits§
- Layout
- A layout that can wrap around routed elements.
Used by
Routerto render layouts around matched routes.
Functions§
- init
- Initializes the router system within a GPUI application context.
- nav_
link - A navigation link that changes the route when clicked.
- outlet
- An outlet is a placeholder in the UI where routed components will be rendered.
- route
- Creates a new
Routeelement. - router
- A simple router component that can hold child elements.
- use_
location - Returns the current Location. This can be useful if you’d like to perform some side effect whenever it changes.
- use_
navigate - Returns a function that lets you navigate programmatically in response to user interactions or effects.
- use_
params - Returns the current route parameters as a map of key-value pairs.
This is useful for accessing dynamic segments in the route path.
For example, if you have a route defined as
/user/{id}, you can access theidparameter using this hook.
Derive Macros§
- Into
Layout - #[derive(IntoLayout)] is used to create a Layout with outlet.