aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
blob: 63ad29b7088f553b6b2be5f32c85af0574e389fb (plain) (blame)
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
27
28
use std::array;
use std::io;
use std::sync::mpsc;

use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
    #[error("io: {0}")]
    Io(#[from] io::Error),
    #[error("mpsc recv: {0}")]
    MpscRecv(#[from] mpsc::RecvError),
    #[error("mpsc send Vec<u8>")]
    MpscSendU8Vec,
    #[error("array try from slice: {0}")]
    ArrayTryFromSlice(#[from] array::TryFromSliceError),

    #[error("pcap: {0}")]
    Pcap(#[from] pcap::Error),
}

impl From<mpsc::SendError<Vec<u8>>> for Error {
    fn from(_: mpsc::SendError<Vec<u8>>) -> Self {
        Self::MpscSendU8Vec
    }
}

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