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
42
43
44
45
46
47
48
49
50
51
52
use thiserror::Error;
/// Errors generated by the relay protocol.
#[derive(Debug, Error)]
pub enum Error {
/// Error generated a buffer is too large.
#[error("buffer exceeds maximum size {0}")]
MaxBufferSize(usize),
/// Error generated when encoding identity bytes are invalid.
#[error("encoding identity bytes are invalid")]
BadEncodingIdentity,
/// Error generated when encoding versions are mismatched.
#[error("encoding version is not supported, expecting version {0} but got version {1}")]
EncodingVersion(u16, u16),
/// Error generated decoding the kind for an encoding is invalid.
#[error("invalid encoding kind identifier {0}")]
EncodingKind(u8),
/// Error generated when the noise pattern in a PEM does not
/// match the pattern in use by the protocol.
#[error(r#"noise protocol pattern mismatch, expecting "{0}""#)]
PatternMismatch(String),
/// Error generated when the PEM encoding does not match
/// the expected format.
#[error("encoding in PEM is invalid")]
BadKeypairPem,
/// Error generated when a node expects to be in the transport
/// protocol state.
#[error("not transport protocol state")]
NotTransportState,
/// Error generated by input/output.
#[error(transparent)]
Io(#[from] std::io::Error),
/// Error generated by the noise protocol library.
#[error(transparent)]
Snow(#[from] snow::error::Error),
/// Error generated decoding PEM data.
#[error(transparent)]
Pem(#[from] pem::PemError),
/// Error generated serializing or deserializing JSON.
#[error(transparent)]
Json(#[from] serde_json::Error),
}