pub trait BuilderChain<R> {
// Required methods
fn begin_class<H: Into<CmdStr>>(
self,
name: &str,
help_msg: H,
) -> BuilderResult<R>;
fn end_class(self) -> BuilderResult<R>;
fn add_action<H: Into<CmdStr>, F: FnMut(&mut dyn Write, &[&str]) -> R + Send + 'static>(
self,
name: &str,
help_msg: H,
closure: F,
) -> BuilderResult<R>;
fn root(self) -> BuilderResult<R>;
fn into_commander(self) -> Result<Commander<R>, BuildError>;
}
Expand description
The common functions across a Builder
or a BuilderResult
.
See module level documentation for more information.
Required Methods§
Sourcefn begin_class<H: Into<CmdStr>>(
self,
name: &str,
help_msg: H,
) -> BuilderResult<R>
fn begin_class<H: Into<CmdStr>>( self, name: &str, help_msg: H, ) -> BuilderResult<R>
Start a new nested class. If the name already exists a BuildError
will be returned.
Sourcefn end_class(self) -> BuilderResult<R>
fn end_class(self) -> BuilderResult<R>
Close a class and move to it’s parent.
If no parent exists (this function is called on the root), a BuildError
will be returned.
Sourcefn add_action<H: Into<CmdStr>, F: FnMut(&mut dyn Write, &[&str]) -> R + Send + 'static>(
self,
name: &str,
help_msg: H,
closure: F,
) -> BuilderResult<R>
fn add_action<H: Into<CmdStr>, F: FnMut(&mut dyn Write, &[&str]) -> R + Send + 'static>( self, name: &str, help_msg: H, closure: F, ) -> BuilderResult<R>
Add an action. The closure type gives the arguments after the action command as an array of strings.
Sourcefn root(self) -> BuilderResult<R>
fn root(self) -> BuilderResult<R>
Navigates to the root class, closing out the classes as it goes.
Sourcefn into_commander(self) -> Result<Commander<R>, BuildError>
fn into_commander(self) -> Result<Commander<R>, BuildError>
Finishes the construction of the command tree and returns the build Commander
.
§Note
This can be called even when not on a root class. The implmentation will continue to call end_class
until the root is reached,
short-circuiting the closing out process.
If an error is propogating through then the function will error. If there was no error (ie into_commander
was called on a Builder
instance)
then this function should not fail.
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.