codec_cbor/general/
error.rs1use thiserror::Error;
6
7pub use codec_proto::generated::proto::reallyme::codec::v1::CodecGeneralCborErrorReason as ErrorReason;
9
10#[derive(Clone, Copy, Debug, Eq, Error, PartialEq)]
12#[error("general CBOR: {reason}")]
13pub struct CborError {
14 reason: ErrorReason,
15}
16
17impl CborError {
18 #[must_use]
20 pub const fn new(reason: ErrorReason) -> Self {
21 Self { reason }
22 }
23
24 #[must_use]
26 pub const fn reason(self) -> ErrorReason {
27 self.reason
28 }
29}
30
31pub(super) const fn error(reason: ErrorReason) -> CborError {
32 CborError::new(reason)
33}