Skip to main content

ephemeris_forge_forgejo/api/request/
deploy_keys.rs

1use facet::Facet;
2
3use crate::config::DeployKey;
4
5/// `CreateKeyOption`, with every property the spec lists.
6#[derive(Clone, Debug, Eq, Facet, PartialEq)]
7pub struct CreateKeyOption {
8    /// The key's title.
9    pub title: String,
10    /// The public key.
11    pub key: String,
12    /// Whether the key can only read.
13    pub read_only: bool,
14}
15
16impl CreateKeyOption {
17    /// The body that creates the key titled `title` as declared.
18    #[must_use]
19    pub fn new(title: &str, key: &DeployKey) -> Self {
20        Self {
21            title: title.to_owned(),
22            key: key.key.trim().to_owned(),
23            read_only: key.read_only,
24        }
25    }
26}