Add a subscription to a given `hookname`
(mut self, hookname: &str, callback: C)
| 159 | |
| 160 | /// Add a subscription to a given `hookname` |
| 161 | pub fn hook<C, F>(mut self, hookname: &str, callback: C) -> Self |
| 162 | where |
| 163 | C: Send + Sync + 'static, |
| 164 | C: Fn(Plugin<S>, Request) -> F + 'static, |
| 165 | F: Future<Output = Response> + Send + Sync + 'static, |
| 166 | { |
| 167 | self.hooks.insert( |
| 168 | hookname.to_string(), |
| 169 | Hook { |
| 170 | callback: Box::new(move |p, r| Box::pin(callback(p, r))), |
| 171 | }, |
| 172 | ); |
| 173 | self |
| 174 | } |
| 175 | |
| 176 | /// Register a custom RPC method for the RPC passthrough from the |
| 177 | /// main daemon |