clam_client/
error.rs

1//! Simple error interface for clam_client. This simply wraps other common error types, the reason
2//! for this is two-fold:
3//! 
4//! * Enable propogation of errors all the way up the chain.
5//! * Provide one simple error handling mechanism to the caller.
6//! 
7//! Whilst this may not be the most optimal approach, and is subject to change, it does make
8//! client side handling and result propogation very simple.
9
10/// `ClamError` is the primary interface for all errors emitted by `clam_client`.
11#[derive(Debug, Fail)]
12pub enum ClamError {
13    /// Generated when an invalid IP address is supplied to `ClamClient::new(..)`
14    #[fail(display = "{}", _0)]
15    InvalidIpAddress(::std::net::AddrParseError),
16    /// Generated when a`ClamClient` is unable to connect to the specified ClamAV socket
17    #[fail(display = "{}", _0)]
18    ConnectionError(::std::io::Error),
19    /// Generated when the command issued cannot be sucesffully written to the ClamAV socket
20    #[fail(display = "{}", _0)]
21    CommandError(::std::io::Error),
22    /// Generated when the ClamAV response cannot be parsed by `clam_client::response::T`
23    #[fail(display = "Could not parse: {}", _0)]
24    InvalidData(::std::string::String),
25    /// Generated when an integer cannot be parsed, wrapped in `ClamError` for ease
26    #[fail(display = "{}", _0)]
27    IntParseError(::std::num::ParseIntError),
28    /// Generated when a date cannot be parsed by `chrono`, wrapped in `ClamError` for ease
29    #[fail(display = "{}", _0)]
30    DateParseError(::chrono::format::ParseError),
31    /// Genarated when the data length written to the ClamD socket exceeds 2^32
32    #[fail(display = "Invalid data length sent: {}", _0)]
33    InvalidDataLengthError(usize)
34}