2024-05-29 19:22:05 +01:00
|
|
|
use crate::{ApiToken, ForgeAlias, ForgeConfig, ForgeType, Hostname, User};
|
2024-05-11 19:46:20 +01:00
|
|
|
|
|
|
|
/// The derived information about a Forge, used to create interactions with it
|
2024-05-19 20:02:06 +01:00
|
|
|
#[derive(Clone, Default, Debug, derive_more::Constructor, derive_with::With)]
|
2024-05-11 19:46:20 +01:00
|
|
|
pub struct ForgeDetails {
|
2024-05-29 19:22:05 +01:00
|
|
|
forge_alias: ForgeAlias,
|
2024-05-15 07:55:05 +01:00
|
|
|
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 {
|
2024-05-29 19:22:05 +01:00
|
|
|
pub const fn forge_alias(&self) -> &ForgeAlias {
|
|
|
|
&self.forge_alias
|
2024-05-15 07:55:05 +01:00
|
|
|
}
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2024-05-29 19:22:05 +01:00
|
|
|
impl From<(&ForgeAlias, &ForgeConfig)> for ForgeDetails {
|
|
|
|
fn from(forge: (&ForgeAlias, &ForgeConfig)) -> Self {
|
2024-05-11 19:46:20 +01:00
|
|
|
Self {
|
2024-05-29 19:22:05 +01:00
|
|
|
forge_alias: 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(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|