Skip to content

Commit

Permalink
minor refactoring of featture "plaintext-before-extension"
Browse files Browse the repository at this point in the history
  • Loading branch information
maebli committed Jun 5, 2024
1 parent 24e333b commit a9813e7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/user_data/value_information.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ impl TryFrom<&[u8]> for ValueInformationBlock {
let vif = ValueInformationField::from(data[0]);
let mut plaintext_vife: Option<ArrayVec<char, 9>> = None;

#[cfg(not(feature = "plaintext-before-extension"))]
let standard_plaintex_vib = true;
#[cfg(feature = "plaintext-before-extension")]
if vif.value_information_contans_ascii() {
let standard_plaintex_vib = false;

if !standard_plaintex_vib && vif.value_information_contains_ascii() {
plaintext_vife = Some(extract_plaintext_vife(&data[1..]));
}

Expand Down Expand Up @@ -45,8 +49,7 @@ impl TryFrom<&[u8]> for ValueInformationBlock {
return Err(DataInformationError::InvalidValueInformation);
}
}
#[cfg(not(feature = "plaintext-before-extension"))]
if vif.value_information_contans_ascii() {
if standard_plaintex_vib && vif.value_information_contains_ascii() {
plaintext_vife = Some(extract_plaintext_vife(&data[offset..]));
}
}
Expand Down Expand Up @@ -82,7 +85,7 @@ pub struct ValueInformationField {
}

impl ValueInformationField {
fn value_information_contans_ascii(&self) -> bool {
fn value_information_contains_ascii(&self) -> bool {
self.data == 0x7C || self.data == 0xFC
}
}
Expand Down

0 comments on commit a9813e7

Please sign in to comment.