spirit icon indicating copy to clipboard operation
spirit copied to clipboard

Custom derive for CfgHelper

Open vorner opened this issue 7 years ago • 1 comments

The CfgHelper is (hopefully) composable from sub-config sections, with adequate attribute annotations (supplying the action and name). This makes it a candidate for custom derive, which could provide the relevant extractors and cut down on boilerplate further.

There should be some option to skip a field from the custom derive.

A brainstorming suggestion for syntax:

#[derive(Deserialize, CfgHelper)]
struct Config {
    #[cfg_helper(name = "listener", action = "handle_conn")]
    listener: HashSet<TcpListen>,

    #[cfg_helper(skip)]
    msg: String,
}

vorner avatar Sep 02 '18 10:09 vorner

Note: it's no longer called a cfg helper. These are either extensions or pipelines. But both would use some kind of boilerplate reducer.

vorner avatar Oct 20 '19 08:10 vorner