j2k_cuda/error/
native_source.rs1use j2k_native::{DecodeError, DecodeErrorClass};
4
5#[derive(Debug, PartialEq, Eq)]
12pub struct NativeBackendError {
13 source: DecodeError,
14}
15
16impl NativeBackendError {
17 pub(crate) const fn decode(source: DecodeError) -> Self {
18 Self { source }
19 }
20
21 pub(crate) fn is_decode_truncated(&self) -> bool {
22 matches!(
23 self.source.classify(),
24 DecodeErrorClass::InputTooShort { .. } | DecodeErrorClass::InputTruncatedAt { .. }
25 )
26 }
27
28 pub(crate) fn is_unsupported(&self) -> bool {
29 matches!(self.source.classify(), DecodeErrorClass::Unsupported { .. })
30 }
31}
32
33impl core::fmt::Display for NativeBackendError {
34 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
35 self.source.fmt(f)
36 }
37}
38
39impl core::error::Error for NativeBackendError {
40 fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
41 Some(&self.source)
42 }
43}