Skip to main content

ephemeris_forge_github/operation/
webhooks.rs

1use std::fmt;
2
3use crate::Webhook;
4
5/// One write to the repository's webhooks.
6#[derive(Clone, Debug, Eq, PartialEq)]
7pub enum Operation {
8    /// Create the webhook.
9    Create {
10        /// The delivery URL.
11        url: String,
12        /// The webhook to create.
13        webhook: Webhook,
14    },
15    /// Update the webhook.
16    Update {
17        /// The delivery URL.
18        url: String,
19        /// The id GitHub gave the webhook.
20        id: u64,
21        /// The desired webhook.
22        webhook: Webhook,
23        /// Whether the content type or the TLS setting changed.
24        config_changed: bool,
25    },
26    /// Delete the webhook.
27    Delete {
28        /// The delivery URL, or the id when GitHub reports none.
29        url: String,
30        /// The id GitHub gave the webhook.
31        id: u64,
32    },
33}
34
35impl fmt::Display for Operation {
36    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37        match self {
38            Self::Create { url, webhook: _ }
39            | Self::Update {
40                url,
41                id: _,
42                webhook: _,
43                config_changed: _,
44            }
45            | Self::Delete { url, id: _ } => write!(f, "webhook {url}"),
46        }
47    }
48}