Skip to main content

ephemeris_forge_forgejo/operation/
deploy_keys.rs

1use std::fmt;
2
3use crate::api::request::CreateKeyOption;
4
5/// One write to the repository's deploy keys.
6///
7/// Forgejo cannot edit a deploy key, so a change is a delete and a create.
8#[derive(Clone, Debug, Eq, PartialEq)]
9pub enum Operation {
10    /// Create a deploy key.
11    Create {
12        /// The request body.
13        body: CreateKeyOption,
14    },
15    /// Delete a deploy key.
16    Delete {
17        /// The key's identifier.
18        id: i64,
19        /// The key's title.
20        title: String,
21    },
22}
23
24impl fmt::Display for Operation {
25    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26        match self {
27            Self::Create { body } => write!(f, "deploy key {}", body.title),
28            Self::Delete { id: _, title } => write!(f, "deploy key {title}"),
29        }
30    }
31}