Skip to main content

zulip_api/message/channel_permission/
can_subscribe_group.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{impl_cow, GroupSetting};
4
5/// Represents a group-setting value defining the set of users who have permission to subscribe themselves to this channel.
6///
7/// Everyone, excluding guests, can subscribe to any public channel irrespective of this setting.  Users in this group can subscribe to a private channel as well.
8///
9/// Note that a user must `have content access` to a channel and permission to administer the channel in order to modify this setting.
10///
11/// **Changes**: New in Zulip 10.0 (feature level 357).
12#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
13pub struct CanSubscribeGroup(pub GroupSetting);
14
15impl CanSubscribeGroup {
16    /// Creates a new [Self].
17    pub const fn new() -> Self {
18        Self(GroupSetting::new())
19    }
20
21    /// Converts the inner representation into a [Self].
22    pub const fn from_inner(val: GroupSetting) -> Self {
23        Self(val)
24    }
25
26    /// Converts the [Self] into the inner representation.
27    pub fn into_inner(self) -> GroupSetting {
28        self.0
29    }
30}
31
32impl Default for CanSubscribeGroup {
33    fn default() -> Self {
34        Self::new()
35    }
36}
37
38impl_cow!(CanSubscribeGroup);