Subscribe to notifications for the given `topic`. The handler is an async function that takes a `Plugin ` and the notification as a `serde_json::Value` as inputs. Since notifications do not expect a result the handler should only report errors while processing. Any error reported while processing the notification will be logged in the cln logs. ``` use cln_plugin::{options, Builder, Error, Plug
(mut self, topic: &str, callback: C)
| 143 | /// .subscribe("connect", connect_handler); |
| 144 | /// ``` |
| 145 | pub fn subscribe<C, F>(mut self, topic: &str, callback: C) -> Builder<S, I, O> |
| 146 | where |
| 147 | C: Send + Sync + 'static, |
| 148 | C: Fn(Plugin<S>, Request) -> F + 'static, |
| 149 | F: Future<Output = Result<(), Error>> + Send + Sync + 'static, |
| 150 | { |
| 151 | self.subscriptions.insert( |
| 152 | topic.to_string(), |
| 153 | Subscription { |
| 154 | callback: Box::new(move |p, r| Box::pin(callback(p, r))), |
| 155 | }, |
| 156 | ); |
| 157 | self |
| 158 | } |
| 159 | |
| 160 | /// Add a subscription to a given `hookname` |
| 161 | pub fn hook<C, F>(mut self, hookname: &str, callback: C) -> Self |