use crate::{Error, Result};
mobius::embedded_config! {
copy;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RuntimeConfig {
pub idle_exit_seconds: u64,
pub storage_limit_bytes: Option<u64>,
pub ingress: Option<std::net::SocketAddr>,
pub require_access_lease: bool,
pub access_grace_seconds: u64,
}
defaults = include_str!("runtime.toml");
}
impl RuntimeConfig {
pub(super) fn validate(&self) -> Result<()> {
super::bounded(
"runtime.idle_exit_seconds",
self.idle_exit_seconds,
0..=31_536_000,
)?;
super::bounded(
"runtime.access_grace_seconds",
self.access_grace_seconds,
0..=86_400,
)?;
if self
.storage_limit_bytes
.is_some_and(|limit| limit < 64 * 1024 * 1024)
{
return Err(Error::Config(
"storage_limit_bytes must be at least 64 MiB".into(),
));
}
Ok(())
}
}