(&self, context: HookContext)
| 185 | } |
| 186 | |
| 187 | pub async fn trigger(&self, context: HookContext) -> Vec<HookResult> { |
| 188 | let hooks = self.hooks.read().await; |
| 189 | let mut results = Vec::new(); |
| 190 | |
| 191 | if let Some(hook_list) = hooks.get(&context.event) { |
| 192 | for hook in hook_list { |
| 193 | if !hook.enabled { |
| 194 | continue; |
| 195 | } |
| 196 | let result = (hook.handler)(context.clone()).await; |
| 197 | results.push(result); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | results |
| 202 | } |
| 203 | |
| 204 | pub async fn remove(&self, event: &HookEvent, name: &str) -> bool { |
| 205 | let mut hooks = self.hooks.write().await; |
no test coverage detected