pub fn parse_option<O: PluginOption>(
s: &str,
) -> Result<O::Value, OptionParseError>Expand description
Parse a get-option result string into the option’s typed value (slice
PH7.10b). get-option returns the value formatted by the native
OptionType; this reads it back into O::Value via its FromStr.
§Errors
A malformed string is a typed OptionParseError carrying the FromStr
error’s message, never a panic.
§Examples
use lattice_plugin_sdk::{PluginOption, parse_option};
/// Whether long lines wrap.
#[derive(PluginOption)]
#[option(default = "true")]
struct WrapLines(bool);
assert_eq!(WrapLines::NAME, "wrap-lines");
assert_eq!(parse_option::<WrapLines>("false"), Ok(false));
assert!(parse_option::<WrapLines>("yes").is_err());