use std::{fmt::Display, hash::Hash};
pub(crate) trait DataCharacterTrait: Display + Eq + PartialEq + Hash {
fn getValue(&self) -> u32;
fn getChecksumPortion(&self) -> u32;
}
#[derive(Hash, PartialEq, Eq, Debug, Copy, Clone)]
pub struct DataCharacter {
value: u32,
checksumPortion: u32,
}
impl DataCharacterTrait for DataCharacter {
fn getValue(&self) -> u32 {
self.value
}
fn getChecksumPortion(&self) -> u32 {
self.checksumPortion
}
}
impl DataCharacter {
pub fn new(value: u32, checksumPortion: u32) -> Self {
Self {
value,
checksumPortion,
}
}
}
impl Display for DataCharacter {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}({})", self.value, self.checksumPortion)
}
}