rgb-cln/plugins/grpc-plugin/src
Erik De Smedt 74d13bb334 cln_plugin: Request value as rust primitive
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`.
2024-02-08 15:37:44 +01:00
..
main.rs cln_plugin: Request value as rust primitive 2024-02-08 15:37:44 +01:00
tls.rs grpc: make the mTLS private keys user-readable only 2023-03-24 00:23:43 +00:00