pub trait Handler:
Sync
+ Send
+ AnySync {
// Required method
fn handle<'life0, 'life1, 'async_trait>(
self: Arc<Self>,
ctx: &'life0 Arc<dyn Context>,
argv: Vec<String>,
cmd: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn verb(&self, _ctx: &Arc<dyn Context>) -> Option<&'static str> { ... }
fn condition(&self, ctx: &Arc<dyn Context>) -> bool { ... }
fn help(&self, _ctx: &Arc<dyn Context>) -> &'static str { ... }
fn dyn_help(&self, _ctx: &Arc<dyn Context>) -> String { ... }
fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 Arc<dyn Context>,
_cmd: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<String>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn start<'life0, 'async_trait>(
self: Arc<Self>,
_ctx: &'life0 Arc<dyn Context>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn stop<'life0, 'async_trait>(
self: Arc<Self>,
_ctx: &'life0 Arc<dyn Context>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
A single command handler, identified by a verb, that can be registered
with a HandlerCli and invoked when its verb is entered.
Required Methods§
Sourcefn handle<'life0, 'life1, 'async_trait>(
self: Arc<Self>,
ctx: &'life0 Arc<dyn Context>,
argv: Vec<String>,
cmd: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
self: Arc<Self>,
ctx: &'life0 Arc<dyn Context>,
argv: Vec<String>,
cmd: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Executes the command with the parsed argument vector and raw command line.
Provided Methods§
Sourcefn verb(&self, _ctx: &Arc<dyn Context>) -> Option<&'static str>
fn verb(&self, _ctx: &Arc<dyn Context>) -> Option<&'static str>
Returns the command verb this handler responds to, or None to disable it.
Sourcefn condition(&self, ctx: &Arc<dyn Context>) -> bool
fn condition(&self, ctx: &Arc<dyn Context>) -> bool
Returns whether this handler should be registered in the given context.
Sourcefn help(&self, _ctx: &Arc<dyn Context>) -> &'static str
fn help(&self, _ctx: &Arc<dyn Context>) -> &'static str
Returns static help text describing the command.
Sourcefn dyn_help(&self, _ctx: &Arc<dyn Context>) -> String
fn dyn_help(&self, _ctx: &Arc<dyn Context>) -> String
Returns dynamically generated help text, used when help is empty.
Sourcefn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 Arc<dyn Context>,
_cmd: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<String>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn complete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 Arc<dyn Context>,
_cmd: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<String>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Returns completion candidates for the command’s arguments, if any.
Implementations§
Source§impl dyn Handler
impl dyn Handler
pub fn is<_T>(&self) -> bool
pub fn downcast_ref<_T>(&self) -> Result<&_T, TypeMismatch>
pub fn downcast_mut<_T>(&mut self) -> Result<&mut _T, TypeMismatch>
pub fn downcast<_T>( self: Box<Self>, ) -> Result<Box<_T>, DowncastError<Box<Self>>>
pub fn downcast_rc<_T>( self: Rc<Self>, ) -> Result<Rc<_T>, DowncastError<Rc<Self>>>
pub fn downcast_arc<_T>(
self: Arc<Self>,
) -> Result<Arc<_T>, DowncastError<Arc<Self>>>where
_T: AnySync,
Self: DowncastSync<_T>,
Trait Implementations§
Source§impl<_T> Downcast<_T> for dyn Handlerwhere
_T: Any,
impl<_T> Downcast<_T> for dyn Handlerwhere
_T: Any,
fn is_type(&self) -> bool
fn downcast_ref(&self) -> Result<&T, TypeMismatch>
fn downcast_mut(&mut self) -> Result<&mut T, TypeMismatch>
fn downcast(self: Box<Self>) -> Result<Box<T>, DowncastError<Box<Self>>>
fn downcast_rc(self: Rc<Self>) -> Result<Rc<T>, DowncastError<Rc<Self>>>
Source§impl<_T> DowncastSync<_T> for dyn Handlerwhere
_T: AnySync,
impl<_T> DowncastSync<_T> for dyn Handlerwhere
_T: AnySync,
fn downcast_arc(self: Arc<Self>) -> Result<Arc<T>, DowncastError<Arc<Self>>>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".