use crate::context::Context;
use crate::error::{Error, Result};
use crate::host::{Elevation, Floor};
#[derive(Debug, Clone, Copy)]
pub struct Permit {
_only_the_gate_makes_one: (),
}
#[cfg(test)]
impl Permit {
pub(crate) fn for_a_test() -> Permit {
Permit {
_only_the_gate_makes_one: (),
}
}
}
pub(crate) fn gate(ctx: &Context) -> Result<Permit> {
crate::release::check()?;
match ctx.host().floor() {
Floor::Met => {}
Floor::Below { build } => return Err(Error::SystemTooOld { build: Some(build) }),
Floor::Unknown => return Err(Error::SystemTooOld { build: None }),
}
match ctx.host().elevation(ctx) {
Elevation::Normal => {}
Elevation::Elevated { why } => return Err(Error::Elevated { why: Some(why) }),
Elevation::Unknown => return Err(Error::Elevated { why: None }),
}
crate::home::check_absolute(ctx)?;
Ok(Permit {
_only_the_gate_makes_one: (),
})
}