2024-05-11 19:46:20 +01:00
|
|
|
use crate::{ApiToken, ForgeConfig, ForgeName, ForgeType, Hostname, User};
|
|
|
|
|
|
|
|
/// The derived information about a Forge, used to create interactions with it
|
2024-05-15 07:55:05 +01:00
|
|
|
#[derive(Clone, Debug, derive_more::Constructor)]
|
2024-05-11 19:46:20 +01:00
|
|
|
pub struct ForgeDetails {
|
2024-05-15 07:55:05 +01:00
|
|
|
forge_name: ForgeName,
|
|
|
|
forge_type: ForgeType,
|
|
|
|
hostname: Hostname,
|
|
|
|
user: User,
|
|
|
|
token: ApiToken,
|
2024-05-11 19:46:20 +01:00
|
|
|
// API Token
|
|
|
|
// Private SSH Key Path
|
|
|
|
}
|
2024-05-15 07:55:05 +01:00
|
|
|
impl ForgeDetails {
|
|
|
|
pub const fn forge_name(&self) -> &ForgeName {
|
|
|
|
&self.forge_name
|
|
|
|
}
|
|
|
|
pub const fn forge_type(&self) -> ForgeType {
|
|
|
|
self.forge_type
|
|
|
|
}
|
|
|
|
pub const fn hostname(&self) -> &Hostname {
|
|
|
|
&self.hostname
|
|
|
|
}
|
|
|
|
pub const fn user(&self) -> &User {
|
|
|
|
&self.user
|
|
|
|
}
|
|
|
|
pub const fn token(&self) -> &ApiToken {
|
|
|
|
&self.token
|
|
|
|
}
|
|
|
|
pub fn with_hostname(self, hostname: Hostname) -> Self {
|
|
|
|
let mut me = self;
|
|
|
|
me.hostname = hostname;
|
|
|
|
me
|
|
|
|
}
|
|
|
|
}
|
2024-05-11 19:46:20 +01:00
|
|
|
impl From<(&ForgeName, &ForgeConfig)> for ForgeDetails {
|
|
|
|
fn from(forge: (&ForgeName, &ForgeConfig)) -> Self {
|
|
|
|
Self {
|
|
|
|
forge_name: forge.0.clone(),
|
2024-05-12 22:27:20 +01:00
|
|
|
forge_type: forge.1.forge_type(),
|
2024-05-11 19:46:20 +01:00
|
|
|
hostname: forge.1.hostname(),
|
|
|
|
user: forge.1.user(),
|
|
|
|
token: forge.1.token(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|