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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
use crate::internal::prelude::*;
use crate::model::id::ChannelId;
use std::collections::HashMap;
#[derive(Clone, Debug, Default)]
pub struct EditChannel(pub HashMap<&'static str, Value>);
impl EditChannel {
pub fn bitrate(&mut self, bitrate: u64) -> &mut Self {
self.0.insert("bitrate", Value::Number(Number::from(bitrate)));
self
}
pub fn name<S: ToString>(&mut self, name: S) -> &mut Self {
self.0.insert("name", Value::String(name.to_string()));
self
}
pub fn position(&mut self, position: u64) -> &mut Self {
self.0.insert("position", Value::Number(Number::from(position)));
self
}
pub fn topic<S: ToString>(&mut self, topic: S) -> &mut Self {
self.0.insert("topic", Value::String(topic.to_string()));
self
}
pub fn nsfw(&mut self, nsfw: bool) -> &mut Self {
self.0.insert("nsfw", Value::Bool(nsfw));
self
}
pub fn user_limit(&mut self, user_limit: u64) -> &mut Self {
self.0.insert("user_limit", Value::Number(Number::from(user_limit)));
self
}
#[inline]
pub fn category<C: Into<Option<ChannelId>>>(&mut self, category: C) -> &mut Self {
self._category(category.into());
self
}
fn _category(&mut self, category: Option<ChannelId>) {
self.0.insert("parent_id", match category {
Some(c) => Value::Number(Number::from(c.0)),
None => Value::Null
});
}
#[inline]
pub fn slow_mode_rate(&mut self, seconds: u64) -> &mut Self {
self.0.insert("rate_limit_per_user", Value::Number(Number::from(seconds)));
self
}
}