use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Base64Error {
#[error("invalid base64")]
Invalid,
#[error("base64 input too large")]
InputTooLarge,
#[error("base64 output too large")]
OutputTooLarge,
#[error("invalid base64 limits")]
InvalidLimits,
#[error("base64 length overflow")]
LengthOverflow,
#[error("base64 allocation failed")]
AllocationFailure,
}
impl Base64Error {
#[must_use]
pub const fn reason(
&self,
) -> codec_proto::generated::proto::reallyme::codec::v1::CodecErrorReason {
use codec_proto::generated::proto::reallyme::codec::v1::CodecErrorReason as R;
match self {
Self::Invalid => R::CODEC_ERROR_REASON_BASE_INVALID_BASE64,
Self::InputTooLarge => R::CODEC_ERROR_REASON_BASE_INPUT_TOO_LARGE,
Self::OutputTooLarge => R::CODEC_ERROR_REASON_BASE_OUTPUT_TOO_LARGE,
Self::InvalidLimits => R::CODEC_ERROR_REASON_BASE_INVALID_LIMITS,
Self::LengthOverflow => R::CODEC_ERROR_REASON_BASE_LENGTH_OVERFLOW,
Self::AllocationFailure => R::CODEC_ERROR_REASON_BASE_ALLOCATION_FAILURE,
}
}
}