1#[derive(Debug, PartialEq)]
4pub enum RecordError {
5 Validity,
7 Alignment,
9 Size,
11 OverflowLength,
13 ClientHello(ClientHelloError),
15 ServerHello(ServerHelloError),
17 NotAllowed,
19}
20
21#[derive(Debug, PartialEq)]
22pub enum ClientHelloError {
23 OverflowSesId,
25 OverflowCipherSuites,
27 Extensions(ExtensionsError),
29 CipherSuites(CipherSuitesError),
31}
32
33#[derive(Debug, PartialEq)]
34pub enum ServerHelloError {
35 OverflowSesId,
37 OverflowCipherSuites,
39 Extensions(ExtensionsError),
41 CipherSuites(CipherSuitesError),
43}
44
45#[derive(Debug, PartialEq)]
46pub enum ExtensionsError {
47 OverflowExtensionLen,
49}
50
51#[derive(Debug, PartialEq)]
52pub enum CipherSuitesError {
53 InvalidLength,
55}
56
57use zerocopy::{error::TryCastError, TryFromBytes};
58
59impl RecordError {
60 pub(crate) fn from_zero_copy<Src, Dst: ?Sized + TryFromBytes>(
61 e: TryCastError<Src, Dst>,
62 ) -> Self {
63 match e {
64 TryCastError::Alignment(..) => Self::Alignment,
65 TryCastError::Validity(..) => Self::Validity,
66 TryCastError::Size(..) => Self::Size,
67 }
68 }
69}
70
71#[derive(Debug, PartialEq)]
72pub enum BuilderError {
73 Overflow,
76 SessionIdOverflow,
78 DisjointMutError,
80}