74d13bb334
In the old version requesting the config-value of an option was a little bit tricky. Let's say we want to have a plugin which uses a default port of 1234. ```rust let value = plugin.option("plugin-port"); match value { Some(Value::Integer(_)) => {}, Some(Value::String(_)) => {}, // Can never happen Some(Value::Boolean(_)) => {}, // Can never happen None => {}, // Can never happen } ``` Many users of the `cln_plugin` crate are overly cautious and handle all these error scenario's. Which is completely unneeded. Core Lightning will complain if you put a `String` where an `Integer` is expected and will never send the value to the plug-in. This change makes the API much more ergonomical and actually motivates some of the changes in previous commits. ``` const MY_OPTION : ConfigOption<i64> = ConfigOption::new_i64_with_default( "plugin-port', 1235, "Description"); let value : Result<i64> = plugin.option(MY_OPTION); ``` The result will provide a proper error-message. It is also safe to `unwrap` the result because it will only be triggered if the user neglected to provide the option to the `Builder`. |
||
---|---|---|
.. | ||
main.rs | ||
tls.rs |