Struct RouteHandle
pub struct RouteHandle { /* private fields */ }Expand description
A cloneable controller for one router’s process-local route stack.
Route changes are presentation state: they do not mutate the app document, participate in collaboration, or create undo entries.
Implementations§
§impl RouteHandle
impl RouteHandle
pub fn new<S, I, R>(initial: S, routes: I) -> Result<RouteHandle, RouteError>
pub fn new<S, I, R>(initial: S, routes: I) -> Result<RouteHandle, RouteError>
Create a navigation stack from a finite route registry.
§Errors
Returns an error when the registry is empty, contains a blank name, or
does not contain initial.
pub fn current(&self) -> String
pub fn knows(&self, route: &str) -> bool
pub fn can_back(&self) -> bool
pub fn can_forward(&self) -> bool
pub fn history(&self) -> (Vec<String>, String, Vec<String>)
pub fn push(&self, route: impl Into<String>) -> Result<bool, RouteError>
pub fn push(&self, route: impl Into<String>) -> Result<bool, RouteError>
Push a different route and clear forward history.
§Errors
Returns RouteError::UnknownRoute without changing history.
pub fn replace(&self, route: impl Into<String>) -> Result<bool, RouteError>
pub fn replace(&self, route: impl Into<String>) -> Result<bool, RouteError>
Replace the current entry without extending back history.
§Errors
Returns RouteError::UnknownRoute without changing history.
pub fn back(&self) -> bool
pub fn forward(&self) -> bool
pub fn reset(&self, route: impl Into<String>) -> Result<bool, RouteError>
pub fn reset(&self, route: impl Into<String>) -> Result<bool, RouteError>
Replace the complete history with one registered route.
§Errors
Returns RouteError::UnknownRoute without changing history.
pub fn push_action(
&self,
route: impl Into<String>,
) -> Result<Box<dyn FnMut()>, RouteError>
pub fn push_action( &self, route: impl Into<String>, ) -> Result<Box<dyn FnMut()>, RouteError>
A directly usable super::Button::on_click callback.
§Errors
Returns an error immediately for an unknown route, rather than waiting for the user to click a dead control.
pub fn export_stack(&self) -> RouteSnapshot
pub fn export_stack(&self) -> RouteSnapshot
Export the history for a same-process-session reload.
pub fn adopt_stack(&self, snapshot: &RouteSnapshot) -> Result<bool, RouteError>
pub fn adopt_stack(&self, snapshot: &RouteSnapshot) -> Result<bool, RouteError>
Replace the history when every name is still registered.
§Errors
Returns RouteError::UnknownRoute or
RouteError::RevisionExhausted without changing history.
Trait Implementations§
§impl Clone for RouteHandle
impl Clone for RouteHandle
§fn clone(&self) -> RouteHandle
fn clone(&self) -> RouteHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RouteHandle
impl !RefUnwindSafe for RouteHandle
impl !Send for RouteHandle
impl !Sync for RouteHandle
impl Unpin for RouteHandle
impl UnsafeUnpin for RouteHandle
impl !UnwindSafe for RouteHandle
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