pub fn get_writer(format: &str) -> Option<OutputFormat>Expand description
Convenience factory that returns the OutputFormat variant for a given
format string.
§Accepted values (case-insensitive)
| Input | Variant |
|---|---|
"yaml" | OutputFormat::Yaml |
"registry" | OutputFormat::Registry |
"http_proxy" / "http-proxy" / "httpproxy" | OutputFormat::HttpProxy |
Returns None for unrecognised strings.
§Usage
use apcore_toolkit::output::get_writer;
use apcore_toolkit::output::OutputFormat;
let fmt = get_writer("yaml").unwrap();
assert_eq!(fmt, OutputFormat::Yaml);
// Then instantiate the concrete writer:
match fmt {
OutputFormat::Yaml => { /* use YAMLWriter */ }
OutputFormat::Registry => { /* use RegistryWriter */ }
OutputFormat::HttpProxy => { /* use HTTPProxyRegistryWriter */ }
}