git-next/crates/config/src/forge_details.rs

42 lines
1.1 KiB
Rust
Raw Normal View History

use crate::{ApiToken, ForgeAlias, ForgeConfig, ForgeType, Hostname, User};
/// The derived information about a Forge, used to create interactions with it
#[derive(Clone, Default, Debug, derive_more::Constructor, derive_with::With)]
pub struct ForgeDetails {
forge_alias: ForgeAlias,
forge_type: ForgeType,
hostname: Hostname,
user: User,
token: ApiToken,
// API Token
// Private SSH Key Path
}
impl ForgeDetails {
pub const fn forge_alias(&self) -> &ForgeAlias {
&self.forge_alias
}
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
}
}
impl From<(&ForgeAlias, &ForgeConfig)> for ForgeDetails {
fn from(forge: (&ForgeAlias, &ForgeConfig)) -> Self {
Self {
forge_alias: forge.0.clone(),
forge_type: forge.1.forge_type(),
hostname: forge.1.hostname(),
user: forge.1.user(),
token: forge.1.token(),
}
}
}