Struct RouterContext
pub struct RouterContext { /* private fields */ }router only.Expand description
A collection of router data that manages all routing functionality.
Implementations§
§impl RouterContext
impl RouterContext
pub fn create_global<R>(cfg: RouterConfig<R>) -> RouterContextwhere
R: Routable + 'static,
pub fn create_global<R>(cfg: RouterConfig<R>) -> RouterContextwhere
R: Routable + 'static,
Create a global RouterContext that lives for the entire application lifetime.
This is useful for sharing router state across multiple windows.
This is not a hook, do not use it inside components like you would use_route.
You would usually want to call this in your main function, not anywhere else.
§Example
fn main() {
let router = RouterContext::create_global::<Route>(RouterConfig::default());
launch(
LaunchConfig::new()
.with_window(WindowConfig::new_app(MyApp { router })),
);
}pub fn try_get() -> Option<RouterContext>
pub fn get() -> RouterContext
pub fn can_go_back(&self) -> bool
pub fn can_go_back(&self) -> bool
Check whether there is a previous page to navigate back to.
pub fn can_go_forward(&self) -> bool
pub fn can_go_forward(&self) -> bool
Check whether there is a future page to navigate forward to.
pub fn go_back(&self)
pub fn go_back(&self)
Go back to the previous location.
Will fail silently if there is no previous location to go to.
pub fn go_forward(&self)
pub fn go_forward(&self)
Go back to the next location.
Will fail silently if there is no next location to go to.
pub fn push(
&self,
target: impl Into<NavigationTarget>,
) -> Option<ExternalNavigationFailure>
pub fn push( &self, target: impl Into<NavigationTarget>, ) -> Option<ExternalNavigationFailure>
Push a new location.
The previous location will be available to go back to.
pub fn replace(
&self,
target: impl Into<NavigationTarget>,
) -> Option<ExternalNavigationFailure>
pub fn replace( &self, target: impl Into<NavigationTarget>, ) -> Option<ExternalNavigationFailure>
Replace the current location.
The previous location will not be available to go back to.
pub fn full_route_string(&self) -> String
pub fn full_route_string(&self) -> String
The full route that is currently active. If this is called from inside a child router, this will always return the parent’s view of the route.
pub fn site_map(&self) -> &'static [SiteMapSegment]
pub fn site_map(&self) -> &'static [SiteMapSegment]
Get the site map of the router.
Trait Implementations§
§impl Clone for RouterContext
impl Clone for RouterContext
§fn clone(&self) -> RouterContext
fn clone(&self) -> RouterContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RouterContext
Auto Trait Implementations§
impl Freeze for RouterContext
impl !RefUnwindSafe for RouterContext
impl !Send for RouterContext
impl !Sync for RouterContext
impl Unpin for RouterContext
impl UnsafeUnpin for RouterContext
impl !UnwindSafe for RouterContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more