Skip to main content

FdlArgsTrait

Trait FdlArgsTrait 

Source
pub trait FdlArgsTrait: Sized {
    // Required methods
    fn try_parse_from(args: &[String]) -> Result<Self, String>;
    fn schema() -> Schema;
    fn render_help() -> String;

    // Provided methods
    fn parse() -> Self { ... }
    fn render_help_path(argv: &[String]) -> String { ... }
}
Expand description

Trait implemented by #[derive(FdlArgs)]. Carries the metadata needed to parse argv into a concrete type and to emit the --fdl-schema JSON.

The name is FdlArgsTrait to avoid colliding with the re-exported derive macro FdlArgs (which lives in the derive-macro namespace). Users never refer to this trait directly — the derive implements it.

Required Methods§

Source

fn try_parse_from(args: &[String]) -> Result<Self, String>

Parse from an explicit argv slice. First element is the program name (ignored), following elements are flags/values/positionals.

Source

fn schema() -> Schema

Return the JSON schema for this CLI shape.

Source

fn render_help() -> String

Render --help to a string.

Provided Methods§

Source

fn parse() -> Self

Parse argv into Self. Uses std::env::args() by default.

Source

fn render_help_path(argv: &[String]) -> String

Render --help for a specific argv path (program name first, then the tokens typed). The default ignores the path and returns Self::render_help — correct for a single struct, whose help is context-free.

The enum derive overrides this to peel the leading subcommand token and render that subcommand’s help, recursing for nested trees. An absent or unknown subcommand falls back to the root (command-list) help. This is why bin train --help shows train’s flags rather than the top-level command list.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§