polysig_protocol/
meetings.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use crate::UserId;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashSet;

/// Identifier for meeting points.
pub type MeetingId = uuid::Uuid;

/// Data for a meeting room participant.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct MeetingData {
    /// Public key for the noise transport.
    pub public_key: Vec<u8>,
    /// Verifying key.
    pub verifying_key: Vec<u8>,
    /// Optional application specific associated data.
    pub associated_data: Option<Value>,
}

/// Messages for the meeting server.
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum MeetingRequest {
    /// Create a meeting room.
    NewRoom {
        /// Owner identifier.
        owner_id: UserId,
        /// Slots for all participants.
        slots: HashSet<UserId>,
    },
    /// Join a meeting room.
    JoinRoom {
        /// Meeting identifier.
        meeting_id: MeetingId,
        /// User identifier.
        user_id: UserId,
        /// Data for this participant.
        data: MeetingData,
    },
}

/// Messages for the meeting client.
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum MeetingResponse {
    /// Meeting room was created.
    RoomCreated {
        /// Meeting identifier.
        meeting_id: MeetingId,
        /// Owner identifier.
        owner_id: UserId,
    },
    /// Meeting room is ready.
    RoomReady {
        /// Participants that have joined the room.
        participants: Vec<(UserId, MeetingData)>,
    },
}