1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use thiserror::Error;

/// The Limlog error type.
#[derive(Debug, Error)]
pub enum ErrorType {
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[error("Invalid reader offset, maximum {maximum}, got {got}")]
    InvalidOffset { maximum: usize, got: usize },

    #[error("Channel sending error: {0}")]
    KanalSend(#[from] kanal::SendError),

    #[error("Channel receive error: {0}")]
    KanalRecv(#[from] kanal::ReceiveError),

    #[error("Bincode error: {0}")]
    Bincode(#[from] bincode::Error),

    #[error("Shutdown signal issued")]
    Shutdown,
}

/// A specialized [`Result`] type for Limlog.
pub type Result<T, E = ErrorType> = std::result::Result<T, E>;