use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub enum DiscardReason {
DangerousProduct,
NonCompliantWithLaw,
IntellectualPropertyInfringement,
LicensedPeriodExpired,
MarkingsCannotBeRemoved,
DamagedOrContaminated,
DefectiveBeyondRepair,
OfferedForDonationNotAccepted,
DonatedButNoRecipientFound,
ReusedButNoRecipientFound,
}
impl DiscardReason {
pub const ALL: &'static [Self] = &[
Self::DangerousProduct,
Self::NonCompliantWithLaw,
Self::IntellectualPropertyInfringement,
Self::LicensedPeriodExpired,
Self::MarkingsCannotBeRemoved,
Self::DamagedOrContaminated,
Self::DefectiveBeyondRepair,
Self::OfferedForDonationNotAccepted,
Self::DonatedButNoRecipientFound,
Self::ReusedButNoRecipientFound,
];
#[must_use]
pub fn article_2_point(self) -> char {
match self {
Self::DangerousProduct => 'a',
Self::NonCompliantWithLaw => 'b',
Self::IntellectualPropertyInfringement => 'c',
Self::LicensedPeriodExpired => 'd',
Self::MarkingsCannotBeRemoved => 'e',
Self::DamagedOrContaminated => 'f',
Self::DefectiveBeyondRepair => 'g',
Self::OfferedForDonationNotAccepted => 'h',
Self::DonatedButNoRecipientFound => 'i',
Self::ReusedButNoRecipientFound => 'j',
}
}
#[must_use]
pub fn is_subordinate(self) -> bool {
matches!(self, Self::OfferedForDonationNotAccepted)
}
}