syncweb_core/editorial/role.rs
1use serde::{Deserialize, Serialize};
2
3/// Editorial role assigned to a participant.
4///
5/// These are orthogonal to the existing [`Capability`] sync roles
6/// (Admin / Write / Read) — they gate content lifecycle transitions
7/// rather than data-plane access.
8///
9/// [`Capability`]: crate::folder::syncweb_folder::Capability
10#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash, Serialize, Deserialize)]
11#[non_exhaustive]
12pub enum EditorialRole {
13 /// Full control over the collection's editorial lifecycle.
14 Owner,
15 /// Can create versions, edit entries, and request reviews.
16 Maintainer,
17 /// Can propose edits and respond to review feedback but cannot
18 /// approve or publish.
19 Editor,
20 /// Can approve, request changes, or reject proposed content.
21 Reviewer,
22 /// Can transition approved content to Published.
23 Publisher,
24 /// Read-only consumer of curated content — no editorial actions.
25 #[default]
26 Viewer,
27}
28
29impl EditorialRole {
30 /// Whether a holder of this role may initiate new content versions.
31 #[must_use]
32 pub const fn can_initiate(self) -> bool {
33 matches!(self, Self::Owner | Self::Maintainer | Self::Editor)
34 }
35
36 /// Whether a holder of this role may approve or reject review items.
37 #[must_use]
38 pub const fn can_review(self) -> bool {
39 matches!(self, Self::Owner | Self::Reviewer)
40 }
41
42 /// Whether a holder of this role may publish approved content.
43 #[must_use]
44 pub const fn can_publish(self) -> bool {
45 matches!(self, Self::Owner | Self::Publisher)
46 }
47
48 /// Whether a holder of this role may retract or archive published content.
49 #[must_use]
50 pub const fn can_withdraw(self) -> bool {
51 matches!(self, Self::Owner | Self::Maintainer | Self::Publisher)
52 }
53}