indexbus_transport_shm/
errors.rs

1use std::io;
2
3/// Errors returned by the `indexbus-transport-shm` adapter.
4#[derive(Debug)]
5pub enum Error {
6    /// An I/O error occurred while opening, sizing, or mapping the backing file.
7    Io(io::Error),
8
9    /// The mapped bytes do not contain a compatible v1 layout.
10    ///
11    /// This includes magic/version mismatches, missing capability bits (e.g. blocking requested
12    /// but wake section absent), and uninitialized layouts.
13    Layout(indexbus_core::Error),
14
15    /// The backing file is smaller than the required bytes for the chosen layout/options.
16    RegionTooSmall {
17        /// Minimum number of bytes required.
18        needed: usize,
19        /// Number of bytes available in the mapped file.
20        found: usize,
21    },
22
23    /// The mapping base address is not aligned as required for the layout type.
24    Misaligned {
25        /// The required byte alignment for the target layout type.
26        align: usize,
27    },
28}
29
30impl From<io::Error> for Error {
31    fn from(value: io::Error) -> Self {
32        Self::Io(value)
33    }
34}
35
36impl From<indexbus_core::Error> for Error {
37    fn from(value: indexbus_core::Error) -> Self {
38        Self::Layout(value)
39    }
40}