1use thiserror::Error;
6
7#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum Base64Error {
11 #[error("invalid base64")]
13 Invalid,
14 #[error("base64 input too large")]
16 InputTooLarge,
17 #[error("base64 output too large")]
19 OutputTooLarge,
20 #[error("invalid base64 limits")]
22 InvalidLimits,
23 #[error("base64 length overflow")]
25 LengthOverflow,
26 #[error("base64 allocation failed")]
28 AllocationFailure,
29}
30
31impl Base64Error {
32 #[must_use]
34 pub const fn reason(
35 &self,
36 ) -> codec_proto::generated::proto::reallyme::codec::v1::CodecErrorReason {
37 use codec_proto::generated::proto::reallyme::codec::v1::CodecErrorReason as R;
38 match self {
39 Self::Invalid => R::CODEC_ERROR_REASON_BASE_INVALID_BASE64,
40 Self::InputTooLarge => R::CODEC_ERROR_REASON_BASE_INPUT_TOO_LARGE,
41 Self::OutputTooLarge => R::CODEC_ERROR_REASON_BASE_OUTPUT_TOO_LARGE,
42 Self::InvalidLimits => R::CODEC_ERROR_REASON_BASE_INVALID_LIMITS,
43 Self::LengthOverflow => R::CODEC_ERROR_REASON_BASE_LENGTH_OVERFLOW,
44 Self::AllocationFailure => R::CODEC_ERROR_REASON_BASE_ALLOCATION_FAILURE,
45 }
46 }
47}