INNER CODE UNIT · Rust
load_err
RyanCodrai/turbovec · turbovec-python/src/lib.rs:296
fn load_err(path: &str, e: std::io::Error) -> PyErr {
let msg = format!("{e}: {path}");
if e.kind() == std::io::ErrorKind::NotFound {
pyo3::exceptions::PyFileNotFoundError::new_err(msg)
} else {
pyo3::exceptions::PyIOError::new_err(msg)
}
}
/// Read-lock an index, recovering from poisoning. A panic that escaped
/// a previous call has already surfaced to Python as a PanicException;
/// before the GIL-release change such a panic likewise left the object
/// reachable, so poisoning must not turn every later call into a panic.
/// Python name for a [`turbovec_core::CalibrationState`].
fn calibration_state_name(state: turbovec_core::CalibrationState) -> &'static str {
match state {
turbovec_core::CalibrationState::Uncalibrated => "uncalibrated",
turbovec_core::CalibrationState::Calibrated => "calibrated",