1use core::fmt;
6
7#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
9#[non_exhaustive]
10pub enum CapabilityRejectionKind {
11 UnsupportedFormat,
13 UnsupportedSampling,
15 UnsupportedBitDepth,
17 UnsupportedOperation,
19 MissingPreparedPlan,
21 UnsupportedContainer,
23 GeometryMismatch,
25 ResourceLimit,
27 ContextMismatch,
29 ContractViolation,
31}
32
33#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
35pub struct CapabilityRejection {
36 kind: CapabilityRejectionKind,
37 reason: &'static str,
38}
39
40impl CapabilityRejection {
41 const fn new(kind: CapabilityRejectionKind, reason: &'static str) -> Self {
42 Self { kind, reason }
43 }
44
45 #[must_use]
47 pub const fn unsupported_format(reason: &'static str) -> Self {
48 Self::new(CapabilityRejectionKind::UnsupportedFormat, reason)
49 }
50
51 #[must_use]
53 pub const fn unsupported_sampling(reason: &'static str) -> Self {
54 Self::new(CapabilityRejectionKind::UnsupportedSampling, reason)
55 }
56
57 #[must_use]
59 pub const fn unsupported_bit_depth(reason: &'static str) -> Self {
60 Self::new(CapabilityRejectionKind::UnsupportedBitDepth, reason)
61 }
62
63 #[must_use]
65 pub const fn unsupported_operation(reason: &'static str) -> Self {
66 Self::new(CapabilityRejectionKind::UnsupportedOperation, reason)
67 }
68
69 #[must_use]
71 pub const fn missing_prepared_plan(reason: &'static str) -> Self {
72 Self::new(CapabilityRejectionKind::MissingPreparedPlan, reason)
73 }
74
75 #[must_use]
77 pub const fn unsupported_container(reason: &'static str) -> Self {
78 Self::new(CapabilityRejectionKind::UnsupportedContainer, reason)
79 }
80
81 #[must_use]
83 pub const fn geometry_mismatch(reason: &'static str) -> Self {
84 Self::new(CapabilityRejectionKind::GeometryMismatch, reason)
85 }
86
87 #[must_use]
89 pub const fn resource_limit(reason: &'static str) -> Self {
90 Self::new(CapabilityRejectionKind::ResourceLimit, reason)
91 }
92
93 #[must_use]
95 pub const fn context_mismatch(reason: &'static str) -> Self {
96 Self::new(CapabilityRejectionKind::ContextMismatch, reason)
97 }
98
99 #[must_use]
101 pub const fn contract_violation(reason: &'static str) -> Self {
102 Self::new(CapabilityRejectionKind::ContractViolation, reason)
103 }
104
105 #[must_use]
107 pub const fn kind(self) -> CapabilityRejectionKind {
108 self.kind
109 }
110
111 #[must_use]
113 pub const fn reason(self) -> &'static str {
114 self.reason
115 }
116}
117
118impl fmt::Display for CapabilityRejection {
119 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
120 formatter.write_str(self.reason)
121 }
122}