use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum KeepAliveSetting {
Duration(String),
Seconds(i64),
}
impl KeepAliveSetting {
pub fn duration(d: impl Into<String>) -> Self {
Self::Duration(d.into())
}
pub fn seconds(s: i64) -> Self {
Self::Seconds(s)
}
pub fn unload_immediately() -> Self {
Self::Seconds(0)
}
}
impl From<&str> for KeepAliveSetting {
fn from(s: &str) -> Self {
Self::Duration(s.to_string())
}
}
impl From<i64> for KeepAliveSetting {
fn from(s: i64) -> Self {
Self::Seconds(s)
}
}