INNER CODE UNIT · Rust
calibration_state_name
RyanCodrai/turbovec · turbovec-python/src/lib.rs:310
fn calibration_state_name(state: turbovec_core::CalibrationState) -> &'static str {
match state {
turbovec_core::CalibrationState::Uncalibrated => "uncalibrated",
turbovec_core::CalibrationState::Calibrated => "calibrated",
// `CalibrationState` is `#[non_exhaustive]`; the binding is
// versioned in lockstep with the core, so a new variant here is
// a build that must not ship.
_ => unreachable!("unhandled CalibrationState variant"),
}
}
fn lock_read<T>(lock: &std::sync::RwLock<T>) -> std::sync::RwLockReadGuard<'_, T> {
lock.read()
.unwrap_or_else(std::sync::PoisonError::into_inner)
}
/// Write-lock an index; see [`lock_read`] for the poisoning rationale.
fn lock_write<T>(lock: &std::sync::RwLock<T>) -> std::sync::RwLockWriteGuard<'_, T> {