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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use super::channel;
use super::object::Object;
use super::uuid::UUID;
use std::collections::HashMap;
pub mod respond_with {
#[derive(Debug, Clone, Copy)]
pub struct OccupancyOnly;
#[derive(Debug, Clone, Copy)]
pub struct OccupancyAndUUIDs;
#[derive(Debug, Clone, Copy)]
pub struct Full;
pub trait RespondWith {
type Response;
}
use super::{ChannelInfo, ChannelInfoWithOccupants, ChannelOccupantFullDetails, UUID};
impl RespondWith for OccupancyOnly {
type Response = ChannelInfo;
}
impl RespondWith for OccupancyAndUUIDs {
type Response = ChannelInfoWithOccupants<UUID>;
}
impl RespondWith for Full {
type Response = ChannelInfoWithOccupants<ChannelOccupantFullDetails>;
}
}
#[allow(missing_copy_implementations)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ChannelInfo {
pub occupancy: u64,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ChannelInfoWithOccupants<T> {
pub occupancy: u64,
pub occupants: Vec<T>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ChannelOccupantFullDetails {
pub uuid: UUID,
pub state: Object,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GlobalInfo<T: respond_with::RespondWith> {
pub total_channels: u64,
pub total_occupancy: u64,
pub channels: HashMap<channel::Name, T::Response>,
}