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
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::io;

use thiserror::Error;

#[derive(Debug, Error)]
pub enum ConnError {
    #[error("malformed frame")]
    MalformedFrame,

    #[error("unknown flags settings {0}")]
    UnknownFlags(u8),

    #[error("unknown frame type {0}")]
    UnknownFrameType(u8),

    #[error("frame too large ({0} B)")]
    FrameTooLarge(usize),

    #[error("auth: {0}")]
    Auth(#[from] AuthError),

    #[error("io: {0}")]
    Io(#[from] io::Error),
}

#[derive(Debug, Error)]
pub enum AuthError {
    /// If we can determine it was incorrectly formatted, which might mean we're
    /// unknowingly trying to use incompatible schemes.
    #[error("malformed response to challenge")]
    MalformedResp,

    /// Response to the challenge was invalid, which probably means we're using
    /// at least a superficially compatible scheme but they're trying to lie to
    /// us or something is misconfigured.
    #[error("invalid response to challenge")]
    InvalidResp,

    #[error("unsupported")]
    Unsupported,
}