JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Connection

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨415ff8d

⁨src/listener.rs⁩ - ⁨733⁩ bytes
Raw
1 use std::collections::HashMap;
2
3 use tokio::sync::broadcast::{Receiver, Sender};
4
5 use crate::{
6 command::{repository::RepositoryMessage, MessageKind},
7 model::{instance::Instance, repository::Repository, user::User},
8 };
9
10 #[derive(Default)]
11 pub struct Listeners {
12 listeners: HashMap<ListenerTarget, (Sender<RepositoryMessage>, Receiver<RepositoryMessage>)>,
13 }
14
15 impl Listeners {
16 pub fn add(
17 &mut self,
18 instance: Option<Instance>,
19 user: Option<User>,
20 repository: Option<Repository>,
21 ) -> Receiver<MessageKind> {
22 todo!()
23 }
24 }
25
26 #[derive(Hash)]
27 pub struct ListenerTarget {
28 pub instance: Option<Instance>,
29 pub user: Option<User>,
30 pub repository: Option<Repository>,
31 }
32