#[non_exhaustive]pub struct AuthRequest<'a> { /* private fields */ }Available on crate feature
auth only.Expand description
The context passed to the auth hook: which command is being authorized.
Marked #[non_exhaustive] so future context (roles, the parsed arguments,
…) can be added without a breaking change.
§Examples
use cli_forge::{App, Command};
let mut app = App::new("demo").auth(|req| {
// Only authorize `publish` when some session check passes.
req.command() != "publish" || session_is_valid()
});
app.register(Command::new("publish").requires_auth(true).run(|_| { /* ... */ }));
fn session_is_valid() -> bool { true }Implementations§
Auto Trait Implementations§
impl<'a> Freeze for AuthRequest<'a>
impl<'a> RefUnwindSafe for AuthRequest<'a>
impl<'a> Send for AuthRequest<'a>
impl<'a> Sync for AuthRequest<'a>
impl<'a> Unpin for AuthRequest<'a>
impl<'a> UnsafeUnpin for AuthRequest<'a>
impl<'a> UnwindSafe for AuthRequest<'a>
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