polysig_protocol/
meetings.rs

1use crate::UserId;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4use std::collections::HashSet;
5
6/// Identifier for meeting points.
7pub type MeetingId = uuid::Uuid;
8
9/// Public keys for a participant.
10#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
11#[serde(rename_all = "camelCase")]
12pub struct PublicKeys {
13    /// Public key for the noise transport.
14    pub public_key: Vec<u8>,
15    /// Verifying key.
16    pub verifying_key: Vec<u8>,
17    /// Optional application specific associated data.
18    pub associated_data: Option<Value>,
19}
20
21/// Messages for the meeting server.
22#[derive(Debug, Serialize, Deserialize)]
23#[serde(rename_all = "camelCase")]
24pub enum MeetingRequest {
25    /// Create a meeting room.
26    NewRoom {
27        /// Owner identifier.
28        owner_id: UserId,
29        /// Slots for all participants.
30        slots: HashSet<UserId>,
31    },
32    /// Join a meeting room.
33    JoinRoom {
34        /// Meeting identifier.
35        meeting_id: MeetingId,
36        /// User identifier.
37        user_id: UserId,
38        /// Data for this participant.
39        data: PublicKeys,
40    },
41}
42
43/// Messages for the meeting client.
44#[derive(Debug, Serialize, Deserialize)]
45#[serde(rename_all = "camelCase")]
46pub enum MeetingResponse {
47    /// Meeting room was created.
48    RoomCreated {
49        /// Meeting identifier.
50        meeting_id: MeetingId,
51        /// Owner identifier.
52        owner_id: UserId,
53    },
54    /// Meeting room is ready.
55    RoomReady {
56        /// Participants that have joined the room.
57        participants: Vec<(UserId, PublicKeys)>,
58    },
59}