aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
blob: 0b560f0b42f0ca6eafd67033d8b99ab191eb9591 (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
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("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>;