use internal::prelude::*;
use utils::VecMap;
use model::id::ChannelId;
#[derive(Clone, Debug, Default)]
pub struct EditChannel(pub VecMap<&'static str, Value>);
impl EditChannel {
pub fn bitrate(mut self, bitrate: u64) -> Self {
self.0.insert("bitrate", Value::Number(Number::from(bitrate)));
self
}
pub fn name(mut self, name: &str) -> Self {
self.0.insert("name", Value::String(name.to_string()));
self
}
pub fn position(mut self, position: u64) -> Self {
self.0.insert("position", Value::Number(Number::from(position)));
self
}
pub fn topic(mut self, topic: &str) -> Self {
self.0.insert("topic", Value::String(topic.to_string()));
self
}
pub fn user_limit(mut self, user_limit: u64) -> Self {
self.0.insert("user_limit", Value::Number(Number::from(user_limit)));
self
}
#[inline]
pub fn category<C: Into<Option<ChannelId>>>(self, category: C) -> Self {
self._category(category.into())
}
fn _category(mut self, category: Option<ChannelId>) -> Self {
self.0.insert("parent_id", match category {
Some(c) => Value::Number(Number::from(c.0)),
None => Value::Null
});
self
}
}