INNER CODE UNIT · Rust

reduce_via_bytes

RyanCodrai/turbovec · turbovec-python/src/lib.rs:282

fn reduce_via_bytes<'py>(
    slf: &Bound<'py, PyAny>,
    payload: Bound<'py, PyBytes>,
) -> PyResult<(Bound<'py, PyAny>, (Bound<'py, PyBytes>,))> {
    Ok((slf.get_type().getattr("from_bytes")?, (payload,)))
}

/// Map an `io::Error` from `load` or `write` to Python:
/// `ErrorKind::NotFound` becomes `FileNotFoundError` (so
/// `except FileNotFoundError:` works, matching what the integrations'
/// Python-side `open()` of their JSON side-cars raises for a missing
/// path); every other kind — including permission errors — stays plain
/// `OSError`, as before. The path is appended because the io::Error
/// alone doesn't name the file.
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)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…