Skip to main content

ephemeris_forge_forgejo/operation/
branch_rules.rs

1use std::fmt;
2
3use crate::BranchRule;
4use crate::api::request::EditBranchProtectionOption;
5
6/// One write to a branch rule.
7#[derive(Clone, Debug, Eq, PartialEq)]
8pub enum Operation {
9    /// Create a branch rule with its complete desired body.
10    Create {
11        /// The branch rule's name.
12        name: String,
13        /// The rule's complete desired configuration.
14        rule: BranchRule,
15    },
16    /// Patch only changed fields of an existing branch rule.
17    Patch {
18        /// The branch rule's name.
19        name: String,
20        /// The fields whose desired value differs from the current one.
21        edit: EditBranchProtectionOption,
22    },
23    /// Delete a branch rule.
24    Delete {
25        /// The branch rule's name.
26        name: String,
27    },
28}
29
30impl fmt::Display for Operation {
31    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32        match self {
33            Self::Create { name, rule: _ }
34            | Self::Patch { name, edit: _ }
35            | Self::Delete { name } => {
36                write!(f, "branch rule {name}")
37            }
38        }
39    }
40}