#![allow(clippy::from_over_into)]
use std::ops::{BitOr, BitXor};
use crate::{menu::ItemOption, shims::constants};
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct ItemOptions {
raw: i32
}
impl ItemOptions {
option_getter!(is_selectable, O_SELECTABLE);
option_setter!(set_selectable, O_SELECTABLE);
}
impl BitOr for ItemOptions {
type Output = Self;
fn bitor(self, rhs: Self) -> Self::Output {
Self { raw: self.raw | rhs.raw }
}
}
impl BitXor for ItemOptions {
type Output = Self;
fn bitxor(self, rhs: Self) -> Self::Output {
Self { raw: self.raw ^ rhs.raw }
}
}
impl BitOr<ItemOption> for ItemOptions {
type Output = Self;
fn bitor(self, rhs: ItemOption) -> Self::Output {
match rhs {
ItemOption::Selectable => self.set_selectable(true)
}
}
}
impl BitXor<ItemOption> for ItemOptions {
type Output = Self;
fn bitxor(self, rhs: ItemOption) -> Self::Output {
match rhs {
ItemOption::Selectable => self.set_selectable(false)
}
}
}
impl From<ItemOption> for ItemOptions {
fn from(item_option: ItemOption) -> Self {
Self::default() | item_option
}
}
impl From<i32> for ItemOptions {
fn from(raw: i32) -> Self {
Self { raw }
}
}
impl Into<i32> for ItemOptions {
fn into(self) -> i32 {
self.raw
}
}