1use core::fmt;
4
5#[derive(Clone, Copy, Debug, Eq, PartialEq)]
7pub enum TlsParseError {
8 Incomplete {
10 required: usize,
12 available: usize,
14 },
15 InvalidValue,
17 TrailingBytes,
19}
20
21impl fmt::Display for TlsParseError {
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23 match self {
24 Self::Incomplete {
25 required,
26 available,
27 } => write!(
28 f,
29 "TLS input is incomplete: need {required} bytes, have {available}"
30 ),
31 Self::InvalidValue => f.write_str("invalid TLS vector or value"),
32 Self::TrailingBytes => f.write_str("TLS payload has trailing bytes"),
33 }
34 }
35}
36
37#[derive(Clone, Copy, Debug, Eq, PartialEq)]
39pub enum TlsBuildError {
40 InvalidValue,
42 LengthTooLarge,
44 BufferTooShort {
46 required: usize,
48 available: usize,
50 },
51}
52
53impl fmt::Display for TlsBuildError {
54 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
55 match self {
56 Self::InvalidValue => f.write_str("invalid TLS builder value"),
57 Self::LengthTooLarge => f.write_str("TLS length is not representable"),
58 Self::BufferTooShort {
59 required,
60 available,
61 } => write!(
62 f,
63 "TLS buffer is too short: need {required} bytes, have {available}"
64 ),
65 }
66 }
67}