use std::collections::BTreeMap;
use derive_more::Constructor;
use crate::config::{ForgeAlias, RepoAlias};
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, derive_more::Constructor)]
pub struct ForgeNotification {
forge_alias: ForgeAlias,
repo_alias: RepoAlias,
headers: BTreeMap<String, String>,
body: Body,
}
impl ForgeNotification {
#[must_use]
pub const fn forge_alias(&self) -> &ForgeAlias {
&self.forge_alias
}
#[must_use]
pub const fn repo_alias(&self) -> &RepoAlias {
&self.repo_alias
}
#[must_use]
pub const fn body(&self) -> &Body {
&self.body
}
#[must_use]
pub fn header(&self, header: &str) -> Option<&str> {
self.headers.get(header).map(std::string::String::as_str)
}
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Constructor)]
pub struct Body(String);
impl Body {
#[must_use]
pub fn as_str(&self) -> &str {
self.0.as_str()
}
#[cfg(test)]
pub(crate) fn as_bytes(&self) -> &[u8] {
self.0.as_bytes()
}
}