1#[derive(Debug, thiserror::Error)]
3#[error("TLS {direction} {item}")]
4pub struct TlsCodecError {
5 direction: &'static str,
6 item: &'static str,
7 #[source]
8 source: tls_codec::Error,
9}
10
11impl TlsCodecError {
12 pub fn serialize(item: &'static str) -> impl FnOnce(tls_codec::Error) -> Self {
14 move |source| Self {
15 direction: "serializing",
16 item,
17 source,
18 }
19 }
20
21 pub fn deserialize(item: &'static str) -> impl FnOnce(tls_codec::Error) -> Self {
23 move |source| Self {
24 direction: "deserializing",
25 item,
26 source,
27 }
28 }
29}