Entrypoint

Trait Entrypoint 

Source
pub trait Entrypoint:
    Parser
    + DotEnvParserConfig
    + LoggerConfig {
    // Provided method
    fn entrypoint<F, T>(self, function: F) -> Result<T>
       where F: FnOnce(Self) -> Result<T> { ... }
}
Expand description

blanket implementation to wrap a function with “main()” setup/initialization boilerplate

Refer to required trait bounds for more information and customization options.

§Examples

Don’t copy this code example. Use the macros::entrypoint attribute macro instead.

struct Args {}

// this function "replaces" `main()`
fn entrypoint(args: Args) -> anyhow::Result<()> {
    Ok(())
}

// execute entrypoint from main
fn main() -> anyhow::Result<()> {
    <Args as clap::Parser>::parse().entrypoint(entrypoint)
}

Provided Methods§

Source

fn entrypoint<F, T>(self, function: F) -> Result<T>
where F: FnOnce(Self) -> Result<T>,

run setup/configuration/initialization and execute supplied function

Customize if/as needed with the other entrypoint traits.

§Errors

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.

Implementors§