use crate::utils::UNIT_LETTER_MAP;
use super::utils::{string_to_letter_map, Letter, LetterMapping};
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub struct Reflector {
wiring: LetterMapping,
}
impl Default for Reflector {
fn default() -> Self {
Reflector {
wiring: UNIT_LETTER_MAP,
}
}
}
impl Reflector {
#[must_use]
pub const fn from_static_str(string: &'static str) -> Reflector {
Reflector {
wiring: string_to_letter_map(string),
}
}
}
#[allow(missing_docs)]
pub const REFLECTOR_A: Reflector = Reflector::from_static_str("EJMZALYXVBWFCRQUONTSPIKHGD");
#[allow(missing_docs)]
pub const REFLECTOR_B: Reflector = Reflector::from_static_str("YRUHQSLDPXNGOKMIEBFZCWVJAT");
#[allow(missing_docs)]
pub const REFLECTOR_C: Reflector = Reflector::from_static_str("FVPJIAOYEDRZXWGCTKUQSBNMHL");
#[allow(missing_docs)]
pub const REFLECTOR_B_THIN: Reflector = Reflector::from_static_str("ENKQAUYWJICOPBLMDXZVFTHRGS");
#[allow(missing_docs)]
pub const REFLECTOR_C_THIN: Reflector = Reflector::from_static_str("RDOBJNTKVEHMLFCWZAXGYIPSUQ");
impl core::ops::Index<Letter> for Reflector {
type Output = Letter;
fn index(&self, index: Letter) -> &Self::Output {
&self.wiring[index]
}
}