#[non_exhaustive]pub enum NavError {
RouteNotFound,
InvalidRoute(String),
NavigationCancelled,
}Expand description
Errors that can occur during navigation operations.
Returned by navigation hooks and helper functions when something goes wrong while resolving or activating a route.
§Stability
This enum is #[non_exhaustive]: future minor releases may add new
variants without bumping the major version. Consumers matching on
NavError must include a wildcard arm (_ =>) so the match remains
exhaustive across upgrades.
use yew_nav_link::NavError;
fn describe(err: &NavError) -> &'static str {
match err {
NavError::RouteNotFound => "missing route",
NavError::InvalidRoute(_) => "bad route",
NavError::NavigationCancelled => "cancelled",
// Required because NavError is non_exhaustive.
_ => "unknown navigation error"
}
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
RouteNotFound
The target route does not match any registered route.
InvalidRoute(String)
A route string could not be parsed. Contains a diagnostic message.
Navigation was cancelled before completion.
Implementations§
Sourcepub const fn route_not_found() -> Self
pub const fn route_not_found() -> Self
Creates a NavError::RouteNotFound error.
Sourcepub fn invalid_route<S: Into<String>>(msg: S) -> Self
pub fn invalid_route<S: Into<String>>(msg: S) -> Self
Creates a NavError::InvalidRoute error with the given message.
Creates a NavError::NavigationCancelled error.
Trait Implementations§
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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.