zulip_api/message/realm_create_web_public_stream_policy.rs
1use serde_repr::{Deserialize_repr, Serialize_repr};
2
3use crate::{impl_default, impl_display};
4
5/// A deprecated representation of a superset of the users who have permission to create web-public channels in the organization, available for backwards-compatibility.
6///
7/// Clients should use `can_create_web_public_channel_group` instead.
8///
9/// It is an enum with the following possible values, corresponding to roles/system groups:
10///
11/// - 2: Admins only
12/// - 4: Admins and moderators only
13/// - 6: Nobody
14/// - 7: Owners only
15///
16/// **Changes**: Deprecated in Zulip 10.0 (feature level 280) and replaced by `realm_can_create_web_public_channel_group`,
17/// which supports finer resolution of configurations, resulting in this property being inaccurate following that transition.
18///
19/// **Changes**: Added in Zulip 5.0 (feature level 103).
20///
21/// [permission-level](https://zulip.com/api/roles-and-permissions#permission-levels)
22#[repr(u8)]
23#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize_repr, Serialize_repr)]
24pub enum RealmCreateWebPublicStreamPolicy {
25 /// Admins only
26 AdminsOnly = 2,
27 /// Admins and moderators only
28 Admins = 4,
29 /// Nobody
30 Nobody = 6,
31 /// Owners only
32 OwnersOnly = 7,
33}
34
35impl RealmCreateWebPublicStreamPolicy {
36 /// Represents the string value of the admins only policy.
37 pub const ADMINS_ONLY: &str = "admins_only";
38 /// Represents the string value of the admins or moderators policy.
39 pub const ADMINS: &str = "admins";
40 /// Represents the string value of the nobody policy.
41 pub const NOBODY: &str = "nobody";
42 /// Represents the string value of the owners only policy.
43 pub const OWNERS_ONLY: &str = "owners_only";
44
45 /// Creates a new [Self].
46 pub const fn new() -> Self {
47 Self::AdminsOnly
48 }
49
50 /// Gets the string representation of the [Self].
51 pub const fn as_str(&self) -> &'static str {
52 match self {
53 Self::AdminsOnly => Self::ADMINS_ONLY,
54 Self::Admins => Self::ADMINS,
55 Self::Nobody => Self::NOBODY,
56 Self::OwnersOnly => Self::OWNERS_ONLY,
57 }
58 }
59}
60
61impl_default!(RealmCreateWebPublicStreamPolicy);
62impl_display!(RealmCreateWebPublicStreamPolicy: str);