pub trait NgynGate {
// Provided method
async fn can_activate(cx: &mut NgynContext<'_>) -> bool { ... }
}
Expand description
Trait for implementing a gate.
Gates are how Ngyn determines if a route can activate. Sometimes, a route may need to be guarded by certain conditions. For instance, restricting access to a route based on the user’s role, or checking if the user is authenticated. Typically, gates are used for this purpose.
§Examples
struct AuthGate;
impl NgynGate for AuthGate {
async fn can_activate(cx: &mut NgynContext<'_>) -> bool {
// Check if the user is authenticated
// If the user is authenticated, return true
// Otherwise, return false
false
}
}
Provided Methods§
Sourceasync fn can_activate(cx: &mut NgynContext<'_>) -> bool
async fn can_activate(cx: &mut NgynContext<'_>) -> bool
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.