zulip_api/message/channel_permission/can_send_message_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 post in this channel.
6///
7/// Note that a user must have metadata access to a channel and permission to administer the channel in order to modify this setting.
8///
9/// **Changes**: New in Zulip 10.0 (feature level 333). Previously `stream_post_policy` field used to control the permission to post in the channel.
10#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
11pub struct CanSendMessageGroup(pub GroupSetting);
12
13impl CanSendMessageGroup {
14 /// Creates a new [Self].
15 pub const fn new() -> Self {
16 Self(GroupSetting::new())
17 }
18
19 /// Converts the inner representation into a [Self].
20 pub const fn from_inner(val: GroupSetting) -> Self {
21 Self(val)
22 }
23
24 /// Converts the [Self] into the inner representation.
25 pub fn into_inner(self) -> GroupSetting {
26 self.0
27 }
28}
29
30impl Default for CanSendMessageGroup {
31 fn default() -> Self {
32 Self::new()
33 }
34}
35
36impl_cow!(CanSendMessageGroup);