use std::path::PathBuf;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ProfileId(String);
impl ProfileId {
#[must_use]
pub fn new(value: impl Into<String>) -> Self {
Self(value.into())
}
#[must_use]
pub fn as_str(&self) -> &str {
&self.0
}
}
impl std::fmt::Display for ProfileId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ProtocolKind {
WireGuard,
OpenVpn,
}
impl std::fmt::Display for ProtocolKind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::WireGuard => f.write_str("WireGuard"),
Self::OpenVpn => f.write_str("OpenVPN"),
}
}
}
#[derive(Debug, Clone)]
pub struct Profile {
pub id: ProfileId,
pub display_name: String,
pub protocol: ProtocolKind,
pub config_path: PathBuf,
}
impl Profile {
#[must_use]
pub fn new(
id: ProfileId,
display_name: impl Into<String>,
protocol: ProtocolKind,
config_path: PathBuf,
) -> Self {
Self {
id,
display_name: display_name.into(),
protocol,
config_path,
}
}
}