// SPDX-License-Identifier: MPL-2.0
// Copyright (C) 2026 Petr Hodina <petr.hodina@protonmail.com>

use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    #[error("QRTR control protocol error: {0}")]
    Qrtr(String),

    #[error("QMI protocol error: {0}")]
    Qmi(String),

    #[error("protobuf decode error: {0}")]
    Decode(#[from] prost::DecodeError),

    #[error("protobuf encode error: {0}")]
    Encode(#[from] prost::EncodeError),

    #[error("SSC service not found on QRTR (kernel CONFIG_QRTR enabled? SLPI firmware loaded?)")]
    ServiceNotFound,

    #[error("timed out waiting for SSC response")]
    Timeout,

    #[error("SUID lookup returned no entries for data_type {0:?}")]
    NoSuchSensor(String),
}

pub type Result<T> = std::result::Result<T, Error>;
