steid

@jamesgill /

steid/src/domain/repository/webhook_repo.rs
Rust1.2 KBCode·Blame·History·Raw
1use super::RepositoryResult;
2use crate::domain::{RepoId, Webhook, WebhookId};
3
4/// Persistence for [`Webhook`].
5pub trait WebhookRepository: Send + Sync {
6 fn find(
7 &self,
8 id: &WebhookId,
9 ) -> impl Future<Output = RepositoryResult<Option<Webhook>>> + Send;
10
11 /// Every hook on a repository, oldest first — the order they were added is the
12 /// order they are read in, and a list that reshuffles when one is edited is worse
13 /// than one that grows downward.
14 ///
15 /// Returns inactive hooks too: whether to deliver is the caller's decision, and a
16 /// list that silently omitted the ones that are off would hide the way to turn them
17 /// back on.
18 fn list_by_repo(
19 &self,
20 repo_id: &RepoId,
21 ) -> impl Future<Output = RepositoryResult<Vec<Webhook>>> + Send;
22
23 fn save(&self, webhook: &Webhook) -> impl Future<Output = RepositoryResult<()>> + Send;
24
25 /// Deletes a hook, succeeding if there was nothing to delete.
26 ///
27 /// Its deliveries go with it, through the foreign key: they are that hook's history
28 /// and mean nothing without it.
29 fn delete(&self, id: &WebhookId) -> impl Future<Output = RepositoryResult<()>> + Send;
30}