pub struct Router { /* private fields */ }
Expand description
A struct representing the router for navigation.
Implementationsยง
Sourceยงimpl Router
impl Router
Sourcepub fn new(
history: AnyHistory,
basename: &'static str,
route: &'static str,
components: HashMap<&'static str, ComponentInfo>,
fetching_routes: HashSet<String>,
events: EventListener,
error_component: Html,
pathname: &'static str,
query: Value,
as_path: &'static str,
subscriptions: Vec<Callback<ComponentInfo>>,
component_load_cancel: Callback<()>,
) -> Self
pub fn new( history: AnyHistory, basename: &'static str, route: &'static str, components: HashMap<&'static str, ComponentInfo>, fetching_routes: HashSet<String>, events: EventListener, error_component: Html, pathname: &'static str, query: Value, as_path: &'static str, subscriptions: Vec<Callback<ComponentInfo>>, component_load_cancel: Callback<()>, ) -> Self
Creates a new router instance.
ยงArguments
history
- The history instance for navigation.basename
- The base URL for the router.route
- The default route for the router.components
- A mapping of route names to component information.fetching_routes
- Set of routes currently being fetched.events
- Event listener for handling router events.error_component
- The component to display in case of navigation errors.pathname
- The current pathname of the router.query
- The current query parameters of the router.as_path
- The current path as a string.subscriptions
- List of callbacks for component information updates.component_load_cancel
- Callback for cancelling component loading.
ยงReturns
A new Router
instance.
Sourcepub fn go(&self, delta: isize)
pub fn go(&self, delta: isize)
Navigates to a specific page with a delta
relative to the current page.
ยงArguments
delta
- The number of pages to navigate (positive for forward, negative for backward).
See: https://developer.mozilla.org/en-US/docs/Web/API/History/go
Sourcepub fn replace(&mut self, route: &'static str)
pub fn replace(&mut self, route: &'static str)
Replaces the current history entry with the provided route.
ยงArguments
route
- The route to replace the current history entry.
Sourcepub fn push_with_state(&mut self, route: &'static str, state: &'static str)
pub fn push_with_state(&mut self, route: &'static str, state: &'static str)
Pushes a route onto the history stack with state.
ยงArguments
route
- The route to be pushed.state
- The state to be associated with the route.
Sourcepub fn replace_with_state(&mut self, route: &'static str, state: &'static str)
pub fn replace_with_state(&mut self, route: &'static str, state: &'static str)
Replaces the current history entry with the provided route and state.
ยงArguments
route
- The route to replace the current history entry.state
- The state to be associated with the route.
Sourcepub fn push_with_query(
&mut self,
route: &'static str,
query: &Value,
) -> NavigationResult<()>
pub fn push_with_query( &mut self, route: &'static str, query: &Value, ) -> NavigationResult<()>
Sourcepub fn push_with_query_and_state(
&mut self,
route: &'static str,
query: &Value,
state: &'static str,
) -> NavigationResult<()>
pub fn push_with_query_and_state( &mut self, route: &'static str, query: &Value, state: &'static str, ) -> NavigationResult<()>
Sourcepub fn replace_with_query_and_state(
&mut self,
route: &'static str,
query: &Value,
state: Value,
) -> NavigationResult<()>
pub fn replace_with_query_and_state( &mut self, route: &'static str, query: &Value, state: Value, ) -> NavigationResult<()>
Replaces the current history entry with the provided route, query parameters, and state.
ยงArguments
route
- The route to replace the current history entry.query
- The query parameters to be associated with the route.state
- The state to be associated with the route.
ยงReturns
A NavigationResult
indicating the success of the operation.
Sourcepub fn kind(&self) -> RouterKind
pub fn kind(&self) -> RouterKind
Sourcepub fn prefix_basename<'a>(&self, route_s: &'a str) -> Cow<'a, str>
pub fn prefix_basename<'a>(&self, route_s: &'a str) -> Cow<'a, str>
Trait Implementationsยง
Auto Trait Implementationsยง
impl Freeze for Router
impl !RefUnwindSafe for Router
impl !Send for Router
impl !Sync for Router
impl Unpin for Router
impl !UnwindSafe for Router
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Sourceยงimpl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Sourceยงfn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self
to a value of a Properties
struct.Sourceยงimpl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Sourceยงfn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self
to a value of a Properties
struct.