pub enum ProviderConfig {
Lxd(LxdConfig),
Hetzner(HetznerConfig),
}Expand description
Provider-specific configuration (Domain Type)
Each variant contains the configuration fields specific to that provider
using validated domain types (e.g., ProfileName instead of String).
This is a tagged enum that serializes/deserializes based on the "provider" field.
§Note on Layer Placement
This is a domain type with validated fields. For JSON deserialization,
use ProviderSection in the application layer, then convert to this type.
§Examples
use torrust_tracker_deployer_lib::domain::provider::{ProviderConfig, LxdConfig, Provider};
use torrust_tracker_deployer_lib::domain::ProfileName;
let lxd_config = ProviderConfig::Lxd(LxdConfig {
profile_name: ProfileName::new("torrust-profile").unwrap(),
});
assert_eq!(lxd_config.provider(), Provider::Lxd);
assert_eq!(lxd_config.provider_name(), "lxd");Variants§
Implementations§
Source§impl ProviderConfig
impl ProviderConfig
Sourcepub fn provider(&self) -> Provider
pub fn provider(&self) -> Provider
Returns the provider type.
§Examples
use torrust_tracker_deployer_lib::domain::provider::{ProviderConfig, LxdConfig, Provider};
use torrust_tracker_deployer_lib::domain::ProfileName;
let config = ProviderConfig::Lxd(LxdConfig {
profile_name: ProfileName::new("test").unwrap(),
});
assert_eq!(config.provider(), Provider::Lxd);Sourcepub fn provider_name(&self) -> &'static str
pub fn provider_name(&self) -> &'static str
Returns the provider name as used in directory paths.
This is a convenience method that delegates to self.provider().as_str().
§Examples
use torrust_tracker_deployer_lib::domain::provider::{ProviderConfig, LxdConfig};
use torrust_tracker_deployer_lib::domain::ProfileName;
let config = ProviderConfig::Lxd(LxdConfig {
profile_name: ProfileName::new("test").unwrap(),
});
assert_eq!(config.provider_name(), "lxd");Sourcepub fn provider_display_name(&self) -> &'static str
pub fn provider_display_name(&self) -> &'static str
Returns a human-readable display name for the provider.
This method converts the internal provider identifier to a user-friendly format suitable for display in CLI output, logs, or documentation.
§Examples
use torrust_tracker_deployer_lib::domain::provider::{ProviderConfig, LxdConfig, HetznerConfig};
use torrust_tracker_deployer_lib::domain::ProfileName;
use torrust_tracker_deployer_lib::shared::secrets::ApiToken;
let lxd_config = ProviderConfig::Lxd(LxdConfig {
profile_name: ProfileName::new("test").unwrap(),
});
assert_eq!(lxd_config.provider_display_name(), "LXD");
let hetzner_config = ProviderConfig::Hetzner(HetznerConfig {
api_token: ApiToken::from("token"),
server_type: "cx22".to_string(),
location: "nbg1".to_string(),
image: "ubuntu-24.04".to_string(),
});
assert_eq!(hetzner_config.provider_display_name(), "Hetzner Cloud");Sourcepub fn as_lxd(&self) -> Option<&LxdConfig>
pub fn as_lxd(&self) -> Option<&LxdConfig>
Returns a reference to the LXD configuration if this is an LXD provider.
§Returns
Some(&LxdConfig)if the provider is LXDNoneotherwise
§Examples
use torrust_tracker_deployer_lib::domain::provider::{ProviderConfig, LxdConfig, HetznerConfig};
use torrust_tracker_deployer_lib::domain::ProfileName;
use torrust_tracker_deployer_lib::shared::secrets::ApiToken;
let lxd_config = ProviderConfig::Lxd(LxdConfig {
profile_name: ProfileName::new("test").unwrap(),
});
assert!(lxd_config.as_lxd().is_some());
let hetzner_config = ProviderConfig::Hetzner(HetznerConfig {
api_token: ApiToken::from("token"),
server_type: "cx22".to_string(),
location: "nbg1".to_string(),
image: "ubuntu-24.04".to_string(),
});
assert!(hetzner_config.as_lxd().is_none());Sourcepub fn as_hetzner(&self) -> Option<&HetznerConfig>
pub fn as_hetzner(&self) -> Option<&HetznerConfig>
Returns a reference to the Hetzner configuration if this is a Hetzner provider.
§Returns
Some(&HetznerConfig)if the provider is HetznerNoneotherwise
Trait Implementations§
Source§impl Clone for ProviderConfig
impl Clone for ProviderConfig
Source§impl Debug for ProviderConfig
impl Debug for ProviderConfig
Source§impl<'de> Deserialize<'de> for ProviderConfig
impl<'de> Deserialize<'de> for ProviderConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ProviderConfig
Source§impl PartialEq for ProviderConfig
impl PartialEq for ProviderConfig
Source§impl Serialize for ProviderConfig
impl Serialize for ProviderConfig
impl StructuralPartialEq for ProviderConfig
Source§impl TryFrom<ProviderSection> for ProviderConfig
impl TryFrom<ProviderSection> for ProviderConfig
Source§type Error = CreateConfigError
type Error = CreateConfigError
Auto Trait Implementations§
impl Freeze for ProviderConfig
impl RefUnwindSafe for ProviderConfig
impl Send for ProviderConfig
impl Sync for ProviderConfig
impl Unpin for ProviderConfig
impl UnsafeUnpin for ProviderConfig
impl UnwindSafe for ProviderConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request