spirit
spirit copied to clipboard
Custom derive for CfgHelper
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,
}
Note: it's no longer called a cfg helper. These are either extensions or pipelines. But both would use some kind of boilerplate reducer.