Skip to main content

GoRoute

Struct GoRoute 

Source
pub struct GoRoute { /* private fields */ }
Expand description

One place the router can go: a pattern of path, and the page it builds.

A path is made of segments: a literal (users), a parameter (:id), or a trailing * that takes whatever is left. A top-level route’s path starts with /; a sub-route’s is relative to its parent’s and does not.

Implementations§

Source§

impl GoRoute

Source

pub fn new<W: Widget + 'static>( path: impl Into<String>, builder: impl Fn(&BuildContext<'_>, &GoRouterState) -> W + 'static, ) -> Self

A route answering to path, building its page with builder.

builder is told the GoRouterState — where the location put the person — and may return any widget: a Component, a Box<dyn Widget>, a scaffold.

Source

pub fn name(self, name: impl Into<String>) -> Self

Names the route, so it can be reached without writing its path: GoRouter::go_named.

Source

pub fn routes(self, routes: Vec<GoRoute>) -> Self

The routes under this one. A location that one of them answers to has this route’s page beneath its own.

Source

pub fn redirect( self, redirect: impl Fn(&GoRouterState) -> Option<String> + 'static, ) -> Self

Where to send a navigation heading to this route or below it, if not here — None to let it through.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.