Skip to main content

ephemeris_forge_forgejo/operation/
labels.rs

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